Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
循环期间的objective-c打印_Objective C_Loops - Fatal编程技术网

循环期间的objective-c打印

循环期间的objective-c打印,objective-c,loops,Objective C,Loops,循环期间如何打印 我有一个调用方法的数组 for (NSDictionary *item in allItems) { [self printa:item]; }; 在这种方法中,我有NSLog,并在循环门前打印,但在打印每个元素、每个图像之前等待循环结束 我试过使用积木,但由于某些原因没有用 我正在寻找异步,我该怎么办 编辑-添加更多代码: 这是printa中的代码: 启动方法: -(void)printa:(NSDictionary*)item 代码的一部分: bubble =

循环期间如何打印

我有一个调用方法的数组

for (NSDictionary *item in allItems) {
    [self printa:item];
};
在这种方法中,我有NSLog,并在循环门前打印,但在打印每个元素、每个图像之前等待循环结束

我试过使用积木,但由于某些原因没有用

我正在寻找异步,我该怎么办

编辑-添加更多代码:

这是printa中的代码:

启动方法:

-(void)printa:(NSDictionary*)item
代码的一部分:

bubble = [NSBubbleData dataWithText:testo date:[NSDate dateWithTimeIntervalSinceNow:0] type:BubbleTypeSomeoneElse];
bubble.avatar = [UIImage imageWithData:imgData];
[bubbleData addObject:bubble];
[bubbleTable reloadData];
NSIndexPath *path = [NSIndexPath indexPathForRow:bubbleData.count inSection:0];
[bubbleTable scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionBottom animated:YES];
testo和imgData数据来自服务器,位于NSDictionary中

NSString *testo=[item objectForKey:@"messaggio"];

提前感谢

如果您询问为什么在循环执行期间打印
NSLog
语句,但元素和图像直到循环完成后才渲染,那么您的问题可能是由于循环未在主线程上执行。你说你试过阻塞,但是除非你把阻塞放在主队列上,否则它不会有帮助。我需要查看
printa
中的代码才能确定。

我不明白…循环在结束前被锁定printa中发生了什么?我添加了更多的代码,只是感兴趣的部分没有看到NSLog()语句?谢谢我添加了更多的代码,希望你能帮助我。谢谢