Ich verwende Twitter API, um Tweets zu posten. Manchmal kann das etwas dauern, daher möchte ich den Vorgang "Tweet posting" im Hintergrund durchführen. Dafür ich verwende GCD, wie folgt aus:Grand Central Dispatch (GCD) und asynchrone APIs
- (void)myClassMethodToPostTweet {
dispatch_async(network_queue, ^{
// … construct the tweet message
NSString *tweet = @"…";
// … check if network is available
[self isConnectedToWeb];
// … initialize twitter API
TwitterAPIClass *twitterAPI = [[[TwitterAPIClass alloc] init…] autorelease];
twitterAPI.delegate = self;
twitterAPI.APIKey = ...;
twitterAPI.APISecret = ...;
// … use twitter API to post the tweet
[twitterAPI postTweet:tweet];
});
}
...
/* and when the API reports a successful operation, update the required variables and UI */
...
- (void)twitterAPIDelegateMethodReportingOperationSuccess {
// … update any variables/records
// … update UI
dispatch_async(dispatch_get_main_queue(), ^{
// … UI updation code
});
}
Das Problem ist, ich bin nicht der Delegat Rückruf bekommen! Was vermisse ich?
Welche Twitter API verwenden Sie? –
http://github.com/bengottlieb/Twitter-OAuth-iPhone – Mustafa