I am trying to use NSDictionary in such a way that I can store NSArrays in it, but I can't even get it to work for strings.
_times = [[NSDictionary alloc] init]; NSString *test = @"Test"; [_times setValue:@"testing" forKey:test]; NSLog(@"%@",[_times objectForKey:test]);
In the above code, the error message Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0x8b86540> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Test.'
Why does NSString * not work as a key? In fact, this is what the method requires.
ios objective-c nsstring nsdictionary
Inbl
source share