How to insert object already existing objects in NSMutableArray list
I am getting a problem, while inserting an object into the main List.
[editContactList addObject:edi开发者_高级运维tcontacts];
[editObject.contactList insertObject:editContactList atIndex:0];//error as mutating method sent to immutable object
[editcontacts release];
If you get that particular error, you don't actually have an NSMutableArray
; you have an NSArray
. Which is immutable. (Note that simply casting an NSArray
to NSMutableArray
does nothing, the array itself needs to be an instance of a mutable array, rarely seen with instance variables, especially those made accessible publicly.)
Edit: We're going to need some more information; how are these variables defined, how are they initialized, etc.
精彩评论