Reputation:
I have a NSMutableArray
when I try to delete object from it, object is not being deleted. And when I debug my code there is data in it.
Here is my code -
NSMutableArray *myArray = [array copy];
// array is NSArray which contains data
[myArray removeObjectAtIndex:0];
Upvotes: 3
Views: 141
Reputation: 13354
It will not delete object from this array
because your NSMutableArray
has become Immutable
.
You're making copy of NSArray
instead of it make mutableCopy it will work -
NSMutableArray *myArray = [array mutableCopy];
Or you can also use initWithArray:
method.
NSMutableArray *myArray = [[NSMutableArray alloc] initWithArray:array];
Upvotes: 8