Skip to content

Instantly share code, notes, and snippets.

@MichaelHackett
Created March 18, 2014 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelHackett/9623156 to your computer and use it in GitHub Desktop.
Save MichaelHackett/9623156 to your computer and use it in GitHub Desktop.
Implementation of NSArray shorthand subscripting as found in iOS 6 / OS X 10.8. (Not tested.)
@implementation NSMutableArray (Indexing)
- (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index
{
if (index == [self count]) {
[self addObject:object];
} else {
[self replaceObjectAtIndex:index withObject:object];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment