您的位置:首页 > 移动开发 > IOS开发

读取plist文件

2015-10-08 13:01 357 查看
//取得mainBundle

NSBundle *bundle
= [NSBundle mainBundle];

 //取得文件路径 

NSString *plistPath
= [bundle pathForResource:@"文件名" ofType:@"plist"];

// 或可以写成

NSString *plistPath
= [[NSBundle mainBundle] pathForResource:@"文件名"
ofType:@"plist"]; 

//读取到一个NSDictionary

NSDictionary *dictionary
= [[NSDictionary alloc] initWithContentsOfFile:plistPath]; //读取到一个NSArrayNSArray
*array =
[[NSArray alloc] initWithContentsOfFile:plistPath];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 读取plist文件