Subscripting only on OS X not iOS.
For NSArray:
- (id)objectAtIndexedSubscript:(NSUInteger)index {
return [self objectAtIndex:index];
}
NSMutableArray: - (void)setObject:(id)object atIndexedSubscript:(NSUInteger)index {
if (index < self.count){
if (object)
[self replaceObjectAtIndex:index withObject:object];
else
[self removeObjectAtIndex:index];
} else {
[self addObject:object];
}
}
NSDictionary: - (id)objectForKeyedSubscript:(id)key {
return [self objectForKey:key];
}
NSMutableDictionary: - (void)setObject:(id)object forKeyedSubscript:(id)key {
[self setObject:object forKey:key];
}This isn't my code, but I've been happily using it for a week or so now: https://gist.github.com/3299750
-(id)objectAtIndexedSubscript:(NSUInteger)index;
-(void)setObject:(id)object atIndexedSubscript:(NSUInteger)index;
as weiran has shown for NS(Mutable)Array/NS(Mutable)Dictionary.