我正在使用Twitter API发布tweets。有时这需要一些时间,所以我想在后台执行“Tweet posting”操作。为此,我使用GCD,如下所示:
- (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
});
}
问题是,我没有收到委托回调!我错过了什么?