سؤال

أنا أستخدم API Twitter لنشر التغريدات. في بعض الأحيان ، قد يستغرق هذا بعض الوقت ، لذلك أريد إجراء عملية "نشر تغريدة" في الخلفية. لذلك أنا أستخدم 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
    });
}

المشكلة هي أنني لا أحصل على رد اتصال المندوب! ماذا ينقصني؟

هل كانت مفيدة؟

المحلول

هل حاولت تشغيل اتصال Twitter على الموضوع الرئيسي؟ إذا كان يعمل على الخيط الرئيسي وليس في قائمة انتظار الخلفية ، فقد تكون قد تم تشغيل مشكلات حلقة التشغيل مع NSURLConnection. (مجرد تخمين برية.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top