IOS笔记本----读写.plist文件
轉載于互聯網
寫操作
????NSString *name=[txt1 text];
????NSNumber *phoneNumber=[[NSNumber alloc] initWithInt:[[txt2 text] intValue]];
????NSNumber *age=[[NSNumber alloc] initWithInt:[[txt3 text] intValue]];
????
????NSMutableArray *array=[[NSMutableArray alloc]init];
????[array??addObject:name];
????[array??addObject:phoneNumber];
????[array??addObject:age];
????NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
????NSString *path=[paths????objectAtIndex:0];
????NSString *filename=[path stringByAppendingPathComponent:@"personal.plist"];????
????
????[array writeToFile:filename??atomically:YES];
????[array release];???
?
讀操作
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
????NSString *path=[paths????objectAtIndex:0];
????NSString *filename=[path stringByAppendingPathComponent:@"personal.plist"];
????
????NSMutableArray *array=[[NSMutableArray alloc] initWithContentsOfFile:filename];
????
????txt1.text=[array objectAtIndex:0];
????txt2.text=[[NSString alloc] initWithFormat:@"%d",[[array objectAtIndex:1]intValue]];
????txt3.text=[[NSString alloc] initWithFormat:@"%d",[[array objectAtIndex:2]intValue]];
????[array release];
轉載于:https://www.cnblogs.com/saltedfish/archive/2012/08/10/2631489.html
總結
以上是生活随笔為你收集整理的IOS笔记本----读写.plist文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows平台Android开发环境
- 下一篇: 重复数据删除(De-duplicatio