如何读取plist数据并从中获取int?

时间:2011-02-18 04:28:07

标签: cocos2d-iphone

目前正在使用cocos2d。我有一个plist数据名称myplist.plist。 plist里面都是整数..我如何读取数据和int中的数据?

1 个答案:

答案 0 :(得分:2)

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *dictionaryPath = [path stringbyAppendingPathComponent:@"myplist.plist"];

NSDictionary *integerDictionary = [[NSDictionary alloc] initWithContentsOfFile:dictionaryPath];

int myInteger1 = [[integerDictionary objectForKey:@"integer1"] intValue];
int myInteger2 = [[integerDictionary objectForKey:@"integer2"] intValue];
// etc etc