У меня есть AQGridView, «инициализация» сетки работает отлично, но когда я делаю [gridView reloadData]
, он падает с ошибкой
2012-01-03 21:27:40.338 XXX[8454:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil key'
После нескольких попыток яотследил ошибку, полученную от AQGridView enqueueReusableCells
.Он пытается получить cell.reuseIdentifier
, а его значение nil
по какой-то странной причине.
Вот код для gridView: cellForItemAtindex:
- (AQGridViewCell *)gridView:(AQGridView *)aGridView cellForItemAtIndex:(NSUInteger)index{
static NSString *CellIdentifier = @"SocialCell";
SocialCell *cell = (SocialCell *) [gridView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[SocialCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SocialCell" owner:nil options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[SocialCell class]]){
cell = (SocialCell *)currentObject;
break;
}
}
}
Как я уже сказал, первый запуск работает отлично, но второй запуск (перезагрузка данных) не работает, как ожидалось.Это представление включает в себя всего 7 ячеек, поэтому оно даже не отключается, поэтому я не уверен, почему значение будет равно нулю и аварийно завершится.
Буду признателен за любую информацию по этому вопросу :) Спасибо!