how to handle “sendDidFinish” in sharekit
Asked Answered
R

1

5

I use sharekit with mail/twitter/facebook and I am really new to objective-c. sharekit works well and sends my images like it should.

in my app I have a screenshot function. I want the app to 'freeze' when a screenshot is taken, stopping to send any shake- or touch-event to the scene behind the sharekit-action. in my screenshot-layer I have three buttons which call the shareItem-methods of their specified service, like

[SHKTwitter shareItem:item];

vereything works fine 'till here. but now when the sending is finished (or canceled or errored) I need the app to 'unfreeze', sharekit should tell my app that it is allowed to listen to any touch- or shake-action again.

I am sorry but I think I don't understand the concept of using the delegate here. I mean, is 'sendDidFinish' meant to be inside a delegate? and if so, how could I tell sharekit who is its delegate? or do I have to edit the send-service classes (like SHKItem or SHKFacebook) itself?

please don't downrate me for this question. I really want to get behind this mystery...

Rodriquez answered 14/3, 2012 at 17:50 Comment(0)
R
12

SHKTwitter inherit from SHKOAuthSharer, who inherit from SHKSharer. SHKSharer has a delegate protocol called "SharerDelegate".

So you can use an instance of SHKTwitter, then set it's delegate as :

shkTwitterInstance.shareDelegate = yourDelegateObject.

And implement the delegate method

- (void)sharerFinishedSending:(SHKSharer *)sharer;.

Try that.

EDIT (OTHER, AND MORE POPULAR, SOLUTION)

Also, you can suscribe your object to "SHKSendDidFinish" notification from SHKTwitter object.

[[NSNotificationCenter defaultCenter] addObserver:yourObject selector:@selector(theMethodthatYouWantToExecuteWhenTheNotificationIsRaised:) name:@"SHKSendDidFinish" object:shkTwitterObject];
Rossy answered 14/3, 2012 at 18:38 Comment(7)
other alternative is that you suscribe your object to "SHKSendDidFinish" notification from SHKTwitter object.Rossy
hey, thanx for your response! sounds so easy... :-) how could I subscribe to the notification?Rodriquez
o.k., I found something like [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(your method) name:@"SHKSendDidFinish" object:nil]; and I will try that.Rodriquez
Yes, that is the method that you have to use, [[NSNotificationCenter defaultCenter] addObserver:yourObject selector:@selector(theMethodthatYouWantToExecuteWhenTheNotificationIsRaised:) name:@"SHKSendDidFinish" object:shkTwitterObject];Rossy
do I need to specify the object if I want to use the same method at the end of any send-service?Rodriquez
if you suscribe to SHKTwitter object, the notification should be rised only at the end of send of SHKTwitter object. If you want to add the same behavier to SHKFacebook, you need to suscribe your object for that object also, with a line like: [[NSNotificationCenter defaultCenter] addObserver:yourObject selector:@selector(theMethodthatYouWantToExecuteWhenTheNotificationIsRaised:) name:@"SHKSendDidFinish" object:shkFacebookObject];Rossy
let us continue this discussion in chatRossy

© 2022 - 2024 — McMap. All rights reserved.