How to read a plist data and get int from it?

て烟熏妆下的殇ゞ 提交于 2019-12-12 10:00:44

问题


Currently using cocos2d. I have a plist data name myplist.plist. Inside the plist are all integers.. How do i read the data and the int in it?


回答1:


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


来源:https://stackoverflow.com/questions/5037612/how-to-read-a-plist-data-and-get-int-from-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!