Reputation: 1361
I created a plist titled "appData.plist" in my supporting files section of Xcode. I have a key called "keyone" and am trying to get the value of it. I'm trying to log the value to console with NSLog but its not working.
How do you do this? I've searched google and there are a lot of way but none work for me.
NSString *myFile = [[NSBundle mainBundle] pathForResource: @"appData" ofType: @"plist"];
NSDictionary *myDict = [NSDictionary dictionaryWithContentsOfFile:myFile];
NSString *viewCover = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"keyone"];
This is what i've tried but the whole thing ends in errors, I can't log it and I get an 'unusable variable' error.
Upvotes: 0
Views: 247
Reputation: 3030
The objectForInfoDictionaryKey
method retrieves a value from your app's Info.plist
file, which isn't what you want -- you want to retreive it from your dictionary myDict
. You mentioned that the value is actually a boolean, so replace the last line with
BOOL viewCover = [[myDict objectForKey:@"keyOne"] boolValue];
Upvotes: 1