【发布时间】:2016-07-05 10:32:38
【问题描述】:
我目前已经开始研究 @synchronized 的工作原理,以及它如何锁定对象。
@synchronized(self) {
[self getDataWithCompletionBlock:^{
dispatch_async(dispatch_get_main_queue(), ^{
[refreshControl endRefreshing];
[self.collectionView reloadData];
loadingView.hidden = YES;
self.oneTimeCallReach = NO;
});
}];
}
这完全错了吗?
【问题讨论】:
-
可能吗?在不知道自己要做什么的情况下,很难说是否有问题。这只会在
getDataWithCompletionBlock调用返回之前锁定,在异步调用返回之前不会锁定。
标签: ios synchronization synchronized