I have NSMutableArray and used it like queue for waiting actions.
Example in array:
0: "Do something"
1: "Do something else"
2: "Do something 2"
When I used [myarray removeObjectAtIndex:0] the array is not reordering and next time when I use [myarray objectAtIndex:o] the result is nil.
How can I put "Do something else" in the first index and "Do something 2" in the second index when I remove "Do something"?
/* gcc -framework Cocoa myprogram.m -o myprogram */
#import <Cocoa/Cocoa.h>
int main( int argc, char **argv )
{
NSMutableArray *array = [ [ NSMutableArray alloc ]
initWithObjects: @"1", @"2", @"3",
nil ]; /* don't forget nil */
/* "pop" the first object */
[ array removeObjectAtIndex:0 ];
/* prints "2" as expected */
NSLog( @"%@", [ array objectAtIndex: 0 ] );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With