您可以创建一个NSOperationQueue并添加操作从服务器获取信息,然后观察队列的“操作”键路径。当operations.count == 0时,然后执行您的推送到地图和tableview。
编辑:
你不投票,本身 - 你所观察的财产和接收的任何更改的通知。
将自己添加为队列操作属性的观察者。
[self.runningQueue addObserver:self forKeyPath:@"operations" options:0 context:NULL];
然后执行以下操作:
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if (object == self.runningQueue && [keyPath isEqualToString:@"operations"]) {
if ([self.runningQueue.operations count] == 0) {
// push to table view and map view
}
}
else {
[super observeValueForKeyPath:keyPath ofObject:object
change:change context:context];
}
}
见this thread。
如何轮询队列的状态? – Pablosproject 2012-04-23 17:08:41
@Pablosproject请参阅编辑进行说明。 – tronbabylove 2012-04-23 19:23:54