抱歉,我是 Cocoa 的新手,因为我是 iOS 移动开发的新手。直截了当,我在 Cocoa 上使用 GCD 方法将数据分配给 tableview,但是当我触发它时[tableview reloadData]
它不起作用。这是我的示例代码:
-(void)updateCell{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSIndexPath* indexPath;
// Insert code to be executed on another thread here
if(clean_data){
for (int i=0; i<clean_data.count; i++) {
indexPath= [NSIndexPath indexPathForRow:i inSection:0];
sqCell *cell = (sqCell *)[stockQ cellForRowAtIndexPath:indexPath];
for (int j=0; j<plist.count; j++) {
NSString *a =[[clean_data objectAtIndex:i]objectAtIndex:1];
NSString *b =[[[plist objectAtIndex:j]objectForKey:@"data"]objectAtIndex:0];
if([a isEqualToString:b]){
cell.last.text =[[clean_data objectAtIndex:i]objectAtIndex:1];
cell.change.text = @"1231231312312";
}
}
}
}
dispatch_async(dispatch_get_main_queue(), ^{
// Insert code to be executed on the main thread here
///reload table here
[self reload];
});
});
}
这里方法重新加载数据
-(void)reload{
NSLog(@"reload");
[stockQ setNeedsLayout];
[stockQ setNeedsDisplay];
[stockQ reloadData];
}
控制台显示“重新加载”文本,但没有触发 stockQ UITableCiew .. 我的代码中发生了什么?