0
所以我有以下的通話每次點擊按鈕:問題與多線程/ GCD和使用綜合類
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self populateSpotVenueIndex];
});
-(void)populateSpotVenueIndex
{
@synchronized(self.spotsResults) {
[self.pollVenueIndex removeAllObjects];
PFQuery * query = [PFQuery queryWithClassName:@"Venue"];
for (PFObject * poll in self.spotsResults)
{
[query getObjectInBackgroundWithId:((PFObject *)[poll objectForKey:@"parent"]).objectId block:^(PFObject * object, NSError * error){
if (!error && [object objectForKey:@"name"] && [poll objectForKey:@"question"]) {
[self.pollVenueIndex setObject:[object objectForKey:@"name"] forKey:[poll objectForKey:@"question"]];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
//[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}else
NSLog(@"Error is %@", [error userInfo]);
}];
}
}
}
當我打電話這是第一次它是好的,但稱這是第二次,並出現以下錯誤崩潰:
當我給它一些時間,該線程完成並再次調用它,它給了我這樣的:
我相信這是因爲我正在嘗試使用self.spotsResults,這是其他線程當前使用的...所以我該如何解決這個問題?
對第一個錯誤有什麼想法嗎? – adit