Я разрабатываю приложение для iOS с использованием iOS 5.
У меня проблемы с использованием центральной диспетчеризации для заполнения представления GMGridViewCell.
Проблема не в том, что GridCell сам по себе, но с доступом к данным в GCD.
Вот мой код:
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index
{
//NSLog(@"Creating view indx %d", index);
CGSize size = [self sizeForItemsInGMGridView:gridView];
GMGridViewCell *cell = [gridView dequeueReusableCell];
if (!cell)
{
cell = [[GMGridViewCell alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
}
[[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
dispatch_queue_t fillCellQueue = dispatch_queue_create("Cell fetch queue", NULL);
dispatch_async(fillCellQueue, ^{
SearchGridViewCell *cellView = [UIView loadFromNib:@"SearchGridViewCell" owner:self];
Item *item = [self.foundItems objectAtIndex:index];
cellView.itemImageView.image = [UIImage imageWithData:item.image.thumb];
cellView.itemNameLabel.text = item.name;
cellView.brandImageView.image = [UIImage imageWithData:item.group3.image.thumb];
Attribute *itemAttribute = [item.attributes objectAtIndex:0];
cellView.attributeLabel.text = [itemAttribute.name stringByAppendingFormat:@": "];
[cellView.attributeLabel sizeToFit];
cellView.itemAttributeValueLabel.text = itemAttribute.value;
[cellView.itemAttributeValueLabel sizeToFit];
dispatch_sync(dispatch_get_main_queue(), ^{
[cell addSubview:cellView];
});
});
dispatch_release(fillCellQueue);
return cell;
}
При запуске приложения я получаю следующую ошибку:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'statement is still active'
*** First throw call stack:
(0x1a1f052 0x35b3d0a 0x11cde0a 0x11cd58d 0x11f689f 0x11ec955 0x11d7df4 0x11f6418 0x11f3b62 0x11f3a57 0x11f316b 0x11f2f97 0x11f2b75 0x11f29f2 0x1236e10 0x51de7 0x44ab445 0x44acecf 0x44acd28 0x44ac4af 0x91442b24 0x914446fe)
Чтоя делаю неправильно?
РЕДАКТИРОВАТЬ Дополнительная информация,
Первая строка, которая вызывает исключение:
cellView.itemImageView.image = [UIImage imageWithData:item.image.thumb];
И я считаю, что проблема заключается виз GCD, потому что, когда я запускаю это без GCD, он работает нормально.Но прокрутка сетки немного вялая, поэтому я хочу добавить к ней GCD.