NSDictionary
sをNSNumber
キーとして取得および設定しようとしています。この回答https://stackoverflow.com/a/6891489/194309に従ってやっていると思いますが、以下のコードは null 値を返します。
- (void)viewDidLoad {
[super viewDidLoad];
NSInteger const SET1 = 1;
NSInteger const SET2 = 2;
videoKeyOfTag = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:SET1], @"well",
[NSNumber numberWithInt:SET2], @"great",
nil];
NSLog(@"to see well: %@",[videoKeyOfTag objectForKey:[NSNumber numberWithInt:SET1]]);
}
ログに期待to see well: well
していますが、代わりに、望ましくないものが表示されます。
to see well: (null)
から始めて、キーがsであるからint
どのように呼び出すことができますか?objectForKey
NSDictionary
NSNumber
(最終的には、メタキーとしてNSDictionary
withから値を抽出したいと考えています。)[sender tag]