Array subscripting in Objective-C
If you're not using the iOS 6 SDK, adding this bit of code to your projects precompiled header will allow you on Xcode 4.4 to use array subscripting. It's also perfectly compatible with iOS 6's SDK.
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
@interface NSObject (ArraySubscriptingSupport)
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
- (id)objectForKeyedSubscript:(id)key;
@end
#endif
Written by Jeremy Tregunna
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xcode
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#