Return Result of Completion Block

后端 未结 2 665
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 03:32

So I\'m trying to build a layer on top of the Twitter API (among others) for a project and I need to find a way to return the result of the Twitter actions to the layer of a

2条回答
  •  被撕碎了的回忆
    2020-12-07 04:09

    Since you are using the asynchronous method it is difficult to say when your method will return the data. So you can consider other options to return the result. For example it might be useful to post a notification, send a message, set some property or even show an alert view.

    As for the article' code sample I would try something like the following

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSData *data = [self loadDataWithConditionLock];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self updateUIWithData:data];
        });
    });
    

提交回复
热议问题