iphone 属性列表把数据保存到文件中

将数组存放到文件中

NSArray * array1=[NSArray arrayWithObjects:@"wtw",@"wtm",nil];

[array1 writeToFile:@"/wtqwtq.txt" atomically:YES];

NSArray *get =[NSArray arrayWithContentsOfFile:@"/wtqwtq.txt"];

NSLog(@"%@",get);

 

将字典存放到文件中

NSMutableDictionary  *md;

md = [NSMutableDictionary dictionary];

[md setObject:[@"hello" lengthOfString] forKey:@"hello"];

[md setObject:[@"wangtianqiao" lengthOfString] forKey:@"wangtianqiao"];

 

 [md writeToFile:@"/wtqwtq.txt" atomically:YES];

NSMutableDictionary *get =[NSMutableDictionary dictionaryWithContentsOfFile:@"/wtqwtq.txt"];

NSLog(@"%@",get);

你可能感兴趣的:(iPhone)