Skip to content

Instantly share code, notes, and snippets.

@nakiwo nakiwo/gist:3179598
Created Jul 26, 2012

Embed
What would you like to do?
Xcode4.4 iOS SDKで @yES,@no,array[...],dictionary[...]を使う
// Xcode4.4
// llvm4の機能のうち一部が、
// iOS 5.1 SDK で使えない
//
NSNumber *b = @YES; // error
NSArray *array = @[ @1, @2, @3 ];
NSNumber *n = array[1]; // error
// 対処 (自己責任で)
#if __has_feature(objc_subscripting)
@interface NSArray (HOGEHOGE)
- (id)objectAtIndexedSubscript:(NSUInteger)idx;
@end
@interface NSMutableArray (HOGEHOGE)
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
@end
@interface NSDictionary (HOGEHOGE)
- (id)objectForKeyedSubscript:(id)key;
@end
@interface NSMutableDictionary (HOGEHOGE)
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
@end
#endif
#if __has_feature(objc_bool)
#undef YES
#undef NO
#define YES __objc_yes
#define NO __objc_no
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.