创建好plist文件
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString* path = [[NSBundle mainBundle]pathForResource:@"Data.plist" ofType:nil];
NSArray* arr = [NSArray arrayWithContentsOfFile:path];
NSLog(@"arr:%@",arr);
NSMutableArray* dataArr = [NSMutableArray arrayWithArray:arr];
[dataArr addObject:@"F"];
[dataArr addObject:@"H"];
[dataArr writeToFile:path atomically:YES];
NSArray* arr1 = [NSArray arrayWithContentsOfFile:path];
NSLog(@"arr1:%@",arr1);
NSArray* pathArr = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* docuPath = [pathArr objectAtIndex:0];
NSString* filePath = [docuPath stringByAppendingPathComponent:@"Data.plist"];
NSArray* newArr = [NSArray arrayWithContentsOfFile:filePath];
NSLog(@"newArr:%@",newArr);
[dataArr writeToFile:filePath atomically:YES];
NSArray* newArr2 = [NSArray arrayWithContentsOfFile:filePath];
NSLog(@"newArr2:%@",newArr2);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end