读取plist文件

来源:互联网 发布:海关进出口数据网 编辑:程序博客网 时间:2024/05/01 19:06

//取得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];

0 0
原创粉丝点击