2014-05-19 32 views
0

如何在循环中打印?循环中的objective-c打印

我有谁调用一个方法

for (NSDictionary *item in allItems) { 
    [self printa:item]; 
}; 

在该方法中的阵列我的NSLog并打印dooring环路,但等待循环结束前的打印每元素,每隔图像。

我尝试了块,但由于某些原因不起作用。

我在寻找asyncronous,我该怎么办?

编辑 - 添加更多的代码:

这是printa代码:

启动方式:

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数据:

-(void)printa:(NSDictionary*)item 

部分代码来自服务器,并在NSDictionary里面

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

在此先感谢

+0

我不明白... – CW0007007

+0

循环被锁定,直到结束 –

+0

在printa中会发生什么? – CW0007007

回答

0

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

+0

谢谢我添加更多的代码,我希望你能帮助我。谢谢 –