您可以創建一個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