Monday, 15 July 2013

ios - Mutating method sent to immutable object with NSMutableArray -


itemprop = "text">

I got the error Cancel the application due to exception exception 'NSInternalInconsistencyException', reason: '- [__NSCFRAA Insert object: AtIndex:]: The method to change the invariant object when I add the object to the temporary array at the second time successfully added for the first time but the second time the accident is the app I think that when I add Oregon to an orange, then there is a problem. not The code is crashed.

  - (void) visual applet: Animated (BOOL) (if ([default object foreaki: @ "group"]! = Zero) {nslog (@ "not default default"); ArrGroups = (NSMutableArray *) [default objectForake: @ "group"];} other {NSLog (@ "zero default."); ArrGroups = [[NSMutableArray alloc] init];}} - (zero) warning view: (UIAlertview * ) Warning View Clicked Button at Index: (NSITer) Button Index {NSLog (@ "Button Index ==% LD", (Long) Button Index); // txtCategory = [[AlertViewtextFieldIndindexX: 0] text]; (Button Indent == 1) {// [Adding Self: Self]; NSLog (@ "Add Group Name% =" @, [[Cauted View TextFieldTitEndex: 0] Text ]; [Ergroups adobect: [[AlertViewTextFieldDatindexX: 0] text]]; ** // crash! Here at the time of adding another object or whenever I remove the first object ** Added to NSLog (@ "array . "); [The default set object: Aria Sum For: @ "group"]; [default synchronize]; // [default release]; [TBL group reload data];}  

}

when If I remove the first object at that time, then I replace userdefault with update ARAL, so I have no problem. And I could not find the reason for that accident.

So please explain to me either problem or solution but without understanding the problem, I can not be considered a solution. Please tell why this happens.

Thank you.

There is a problem with specifying an NSMutableArray, it is only

Note: NSUserDefaults always gives an irreversible object.

Ex> NSMutableArray * arrGroups = [[defaults objectForKey: @ "group"] mutableCopy] ;

This guarantees a temporary copy.

There is another way.

  arrGroups = [[NSMutableArray alloc] initWithArray: [default objectForKey: @ "group"]]; // WillAppear in your view where you assign the array to the default  

No comments:

Post a Comment