NSArray subscripting

This commit is contained in:
Dmitry Serov
2017-07-08 16:16:01 +07:00
parent b743b64262
commit 40a7b8879c
22 changed files with 104 additions and 104 deletions

View File

@@ -34,20 +34,20 @@
if (fromIndex == toIndex)
return;
id object = [[self objectAtIndex: fromIndex] retain];
id object = [self[fromIndex] retain];
//shift objects - more efficient than simply removing the object and re-inserting the object
if (fromIndex < toIndex)
{
for (NSUInteger i = fromIndex; i < toIndex; ++i)
[self replaceObjectAtIndex: i withObject: [self objectAtIndex: i+1]];
self[i] = self[i+1];
}
else
{
for (NSUInteger i = fromIndex; i > toIndex; --i)
[self replaceObjectAtIndex: i withObject: [self objectAtIndex: i-1]];
self[i] = self[i-1];
}
[self replaceObjectAtIndex: toIndex withObject: object];
self[toIndex] = object;
[object release];
}