Objective-C Language Mueve el objeto a otro índice


Ejemplo

Mueve azul al principio de la matriz:

NSMutableArray *myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil];

NSUInteger fromIndex = 2;
NSUInteger toIndex = 0;

id blue = [[[self.array objectAtIndex:fromIndex] retain] autorelease];
[self.array removeObjectAtIndex:fromIndex];
[self.array insertObject:blue atIndex:toIndex];

myColors ahora es [@"Blue", @"Red", @"Green", @"Yellow"] .