Hello. I have a tableview in which I add information by pressing a key.
If you write something to the array at the code below, exit the ViewController and re-enter, then when you re-add via [ addObject: ], the program crashes . Log:
'NSInternalInconsistencyException', reason: '- [__ NSCFArray insertObject: atIndex:]:
Add code:
NSMutableArray *fruits; NSUserDefaults *load = [NSUserDefaults stadartUserDefaults]; fruits = [load objectForKey:@"TableLoad"]; // выгружаем сохранение if (fruits == NULL) // если сохранения не было, и fruits обнулился { fruits = [NSMitableArray array]; } [fruits addObject:@"Неважно"]; // Добавление объекта [load setObject:fruits forKey:@"TableLoad"]; // Сохраняем обратно [load synchrinize];
What to do?