- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
[self
performSelectorOnMainThread: @selector(_blockCaller:)
withObject: ^{
[self _reportAchievement:achievement listener:listener];
}
waitUntilDone: YES
];
<...>
- (void) _blockCaller:(void(^)())blockHandler {
blockHandler();
}
guest 28.01.2014 10:23 # −1
Jackos 31.01.2014 11:52 # +1
guest 04.03.2014 15:23 # 0
А вот performSelectorOnMainThread эту проблему решает.
> If the current thread is also the main thread, and you specify YES for this parameter, the message is delivered and processed immediately.
Написано, конечно, не очень красиво, но стоит все-таки подучить матчасть.
guest 25.03.2014 12:33 # 0
dispatch_queue_t main = dispatch_get_main_queue();
if (dispatch_get_current_queue() == main)
block();
else
dispatch_sync(main, block);
guest 11.03.2014 17:21 # 0