Mutating method sent to immutable object
The crash pained me much before i found a simple solution.
When i add an NSObject on NSUSerDefault , and call it again addObject with it, it was always showing the error,
“NSInternalInconsistencyException’, reason: ‘-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'”
Here is where i stuck,
NSDictionary *restaurant = [self.yelpRestaurantList objectAtIndex:((UIButton *)sender).tag];
NSLog(@”btnRestaurant_Click–%@–\n%@–“,[self.savedRestaurantList description],[restaurant description]);
// NSDictionary *dict2 =[restaurant getDictFormat];
[self.savedRestaurantList addObject: restaurant]; // Crashing on addObject
[[NSUserDefaults standardUserDefaults] setObject:self.savedRestaurantList forKey:@”SAVED_RESTAURANT_LIST”];
***********************
Atlast i tried with with NSMutableDictionary instead of NSDictionary. Then it worked like a champ!
////
NSMutableDictionary *restaurant = [self.yelpRestaurantList objectAtIndex:((UIButton *)sender).tag];
Also insert into NSUSerDefault as NSMutableDictionary