Method returning value from asynchronous block with FacebookSDK

后端 未结 3 497
悲&欢浪女
悲&欢浪女 2020-12-18 11:03

What I am trying to do is a Facebook wrapper for the Facebook iOS SDK. Basically the idea is that my ViewController should do nothing but showing ex. my friends that will be

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-18 11:58

    If you are dispatching an asynchronouos block, you can communicate with your UIViewController subclass by calling back to it:

    [self someSelectorWithCallbackData:stuffWhichYouWantToGiveBack];
    

    This will call self to get captured by the block, and so will work as expected. From the relevant method you can refresh the view / reload the tableview / dance a jig as required.

    Depending on the context, you may need to __block scope self, eg

    __block UIViewController *bsself = self;
    

    But if you do the latter, be careful to avoid a retain loop (the build and analysis tools are fairly good at pointing this out).

提交回复
热议问题