【发布时间】:2014-10-08 00:58:38
【问题描述】:
我正在尝试通过 enumerateObjectsUsingBlock 访问 NSArray 槽上的每个项目,因为它让我可以使用快速枚举和评估索引。
当我使用 findObjectsInBackgroundWithBlock 时,
我收到警告:正在主服务器上执行长时间运行的操作 线。中断 warnBlockingOperationOnMainThread() 进行调试。
正如我认为在后台使用的那样不阻塞主线程。这是我的代码,我正在努力实现它,我有两个 UIImageView 容器,我从该查询的关系结果中提取图像。由于只有容器,我认为最好只评估 NSArray 的索引。
不知道如何解决这个警告。
谢谢
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (objects != 0) {
[objects enumerateObjectsUsingBlock:^(PFUser *object, NSUInteger idx, BOOL *stop) {
if (idx == 0) {
PFFile *userProfile = [object objectForKey:@"userPic"];
cell.promoter1.file = userProfile;
cell.promoter1.contentMode = UIViewContentModeScaleAspectFit;
[cell.promoter1 loadInBackground];
cell.promoter1Name.textAlignment = NSTextAlignmentCenter;
cell.promoter1Name.lineBreakMode = NSLineBreakByWordWrapping;
}
if (idx == 1) {
PFFile *userProfile = [object objectForKey:@"userPic"];
cell.promoter2.file = userProfile;
cell.promoter2.contentMode = UIViewContentModeScaleAspectFit;
[cell.promoter2 loadInBackground];
NSAttributedString *promoter1Name;
cell.promoter2Name.textAlignment = NSTextAlignmentCenter;
*stop = YES;
}
}];
}
}];
【问题讨论】:
标签: ios objective-c parse-platform cell fast-enumeration