Instance Method

moveItemAtIndex:inParent:toIndex:inParent:

Moves an item at a given index in the given parent to a new index in a new parent.

Declaration

- (void)moveItemAtIndex:(NSInteger)fromIndex inParent:(id)oldParent toIndex:(NSInteger)toIndex inParent:(id)newParent;

Parameters

fromIndex

Index of the item to be moved.

oldParent

The parent of the item to be moved.

toIndex

Index in the new parent to which the item is moved.

newParent

The parent of the item after it is moved.

Discussion

This method parallels the moveRowAtIndex:toIndex: method of NSTableView. The newParent can be the same as oldParent to reorder an item within the same parent.

You can call this method multiple times within the same beginUpdates/endUpdates block. Moving from an invalid index, or to an invalid index, throws an exception.

See Also

Manipulating Items

- insertItemsAtIndexes:inParent:withAnimation:

Inserts new items at the given indexes in the given parent with the specified optional animations.

- removeItemsAtIndexes:inParent:withAnimation:

Removes items at the given indexes in the given parent with the specified optional animations.