我找到了下面的代码片段,它允许从任何后台线程在主线程上发布NSNotification
.我想知道这是否安全和可以接受的做法?
dispatch_async(dispatch_get_main_queue(),^{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ImageRetrieved"
object:nil
userInfo:imageDict];
});