从plist获取值的方法

aku*_*tsu 6 properties plist cocos2d-iphone ios

我有一个名为NumberX的整数和一个名为PlistX的plist.

int NumberX;
Run Code Online (Sandbox Code Playgroud)

PlistX:

plist中

我想知道我如何使NumberX =值为3

Hec*_*tor 15

试试这个:

NSString *path = [[NSBundle mainBundle] pathForResource:@"PlistX" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
int number = [[[[dict objectForKey:@"One"] objectForKey:@"Two"]objectForKey:@"Three"] intValue];
NSLog(@"%d",number);    
Run Code Online (Sandbox Code Playgroud)