1

TwitterAPIを使用してツイートを投稿しています。時間がかかる場合があるので、バックグラウンドで「ツイート投稿」操作を実行したいと思います。そのために私は次のように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
    });
}

問題は、デリゲートコールバックを取得していないことです。私は何が欠けていますか?

4

1 に答える 1

2

メインスレッドで Twitter 接続を実行してみましたか? バックグラウンド キューではなくメイン スレッドで動作する場合は、 で実行ループの問題が発生している可能性がありますNSURLConnection。(ただの勝手な推測です。)

于 2010-11-25T08:32:39.820 に答える