Skip to content

Instantly share code, notes, and snippets.

@nakiwo
Created July 26, 2012 00:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakiwo/3179598 to your computer and use it in GitHub Desktop.
Save nakiwo/3179598 to your computer and use it in GitHub Desktop.
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