Skip to content

Instantly share code, notes, and snippets.

@paolonl
Last active December 20, 2015 21:59
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 paolonl/6201513 to your computer and use it in GitHub Desktop.
Save paolonl/6201513 to your computer and use it in GitHub Desktop.
Make a class sub-scriptable
/*
Define the proper methods based on the
desired kind of subscripting, indexed
or keyed
*/
@interface IndexedSubscriptable
- (id)objectAtIndexedSubscript:(NSUInteger)idx
- (void)setObject:(id)anObject atIndexedSubscript:(NSUInteger)index
@end
@interface KeyedSubscriptable
- (id)objectForKeyedSubscript:(id)key
- (void)setObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment