NSBundle读写文件

来源:互联网 发布:手机版我的世界家具js 编辑:程序博客网 时间:2024/05/27 21:48
写文件:   
NSString *resourcePath=[[NSBundlemainBundle] resourcePath];

NSString * realPath =[resourcePath stringByAppendingPathComponent:@"a.plist"];

NSLog(@".%@",realPath);

NSArray *array = [NSArray arrayWithObjects:@"11111",@"2222",@"3333",nil];

[array writeToFile:realPathatomically:YES];

读文件:

NSString *resourcePath=[[NSBundle mainBundle] pathForResource:@"a" ofType:@"plist"];

 

NSArray * array = [NSArrayarrayWithContentsOfFile:resourcePath];

for (NSString * str in array) {

       NSLog(@"..%@",str);

}

0 0