Instance Method

moveObjectsAtIndexes:toIndex:

Moves the objects at the specified indexes to the new location.

Declaration

- (void)moveObjectsAtIndexes:(NSIndexSet *)indexes toIndex:(NSUInteger)idx;

Parameters

indexes

The indexes of the objects to move.

idx

The index in the mutable ordered set at which to insert the objects. The objects being moved are first removed from the set, then this index is used to find the location at which to insert the moved objects.

Discussion

For example, the following code results in the contents of mySet being equal to ["a", "c", "b", "d", "e"]:

NSMutableIndexSet *movedObjectIndexes = [NSMutableIndexSet indexSet];
[movedObjectIndexes addIndex: 1];
[movedObjectIndexes addIndex: 3];
 
NSMutableOrderedSet *mySet = [NSMutableOrderedSet orderedSetWithCapacity:5];
[mySet addObject:@"a"];
[mySet addObject:@"b"];
[mySet addObject:@"c"];
[mySet addObject:@"d"];
[mySet addObject:@"e"];
 
[mySet moveObjectsAtIndexes:movedObjectIndexes toIndex:2];

See Also

Adding, Removing, and Reordering Entries

- addObject:

Appends a given object to the end of the mutable ordered set, if it is not already a member.

- addObjects:count:

Appends the given number of objects from a given C array to the end of the mutable ordered set.

- addObjectsFromArray:

Appends to the end of the mutable ordered set each object contained in a given array that is not already a member.

- insertObject:atIndex:

Inserts the given object at the specified index of the mutable ordered set, if it is not already a member.

- setObject:atIndexedSubscript:

Replaces the given object at the specified index of the mutable ordered set.

- insertObjects:atIndexes:

Inserts the objects in the array at the specified indexes.

- removeObject:

Removes a given object from the mutable ordered set.

- removeObjectAtIndex:

Removes a the object at the specified index from the mutable ordered set.

- removeObjectsAtIndexes:

Removes the objects at the specified indexes from the mutable ordered set.

- removeObjectsInArray:

Removes the objects in the array from the mutable ordered set.

- removeObjectsInRange:

Removes from the mutable ordered set each of the objects within a given range.

- removeAllObjects

Removes all the objects from the mutable ordered set.

- replaceObjectAtIndex:withObject:

Replaces the object at the specified index with the new object.

- replaceObjectsAtIndexes:withObjects:

Replaces the objects at the specified indexes with the new objects.

- replaceObjectsInRange:withObjects:count:

Replaces the objects in the receiving mutable ordered set at the range with the specified number of objects from a given C array.

- setObject:atIndex:

Appends or replaces the object at the specified index.

- exchangeObjectAtIndex:withObjectAtIndex:

Exchanges the object at the specified index with the object at the other index.

- filterUsingPredicate:

Evaluates a given predicate against the mutable ordered set’s content and leaves only objects that match.