读取plist文件

 

//取得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];
 
//读取到一个NSArray
NSArray *array = [[NSArray alloc] initWithContentsOfFile:plistPath];

你可能感兴趣的:(ios,plist)