这是在drawRect里面:
NSString *generated = [Entry generateString];
const char *cString = (const char*)[generated UTF8String];
dispatch_queue_t queue = dispatch_queue_create(cString, NULL);*/
dispatch_async(queue, ^{
Media *media = [self.entry.media objectAtIndex:i];
UIImage *image = [media getThumbnail];
dispatch_async(dispatch_get_main_queue(), ^{
int bottom = [JHomeViewCell yOfMessageBottomWithMessageHeight:self.cellInfo.messageHeight
withMonth:self.cellInfo.hasMonth];
CGRect frame = CGRectMake(87 + (68 * i),
bottom,
THUMBNAIL_SIZE.width,
THUMBNAIL_SIZE.height);
[image drawInRect:frame];
});
});
现在,它在 objectAtIndex 行崩溃。这不是一个无效的索引。该代码在此之外工作正常。
编辑:我收到了这个错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'statement is still active'
编辑 2:我放入 NSLogs,第一个获得 media.count。它因同样的错误而崩溃。