All,
I have strings stored in a NSMutableArray. When a certain condition is met elsewhere in the code, the object that is FIRST in the NSMutableArray (read, objectAtIndex:0) gets removed. After it is removed, I need to shift everything down an index. Here is my example:
/*
Index/Value
0 - one
1 - two
2 - three
3 - four
4 - five
5 - six
6 - seven
*/
//removes object...
[mArray removeObjectAtIndex:0];
//I am missing something here...
//I want the value of the array to be as follows:
/*
Index/Value
0 - two
1 - three
2 - four
3 - five
4 - six
5 - seven
*/
What am I missing?
EDIT: The NSMutableArray is stored in NSUserDefaults. Is that what may be causing this not to work?
EDIT2: Because it is stored in NSUserDefaults, it changes to immutable. Check out the accepted answer for the correct way to do it. Details here: crashes my app [NSMutableArray1 removeAllObjects] iphone sdk