码迷,mamicode.com
首页 > 移动开发 > 详细

iOS Plist NSUserDefaults 数据存储

时间:2015-04-23 15:26:44      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

    NSString *home = NSHomeDirectory();

    NSString *docPath = [home stringByAppendingPathComponent:@"Documents"];

    NSString *filePath = [docPath stringByAppendingPathComponent:@"data.plist"];

    NSArray *arrayData = @[@"hanjian",@11,@"jack"];

    [arrayData writeToFile:filePath atomically:YES];

    

    NSArray *readArray = [NSArray arrayWithContentsOfFile:filePath];

 

 

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults setObject:@"name" forKey:@"name"];

    [defaults setInteger:10 forKey:@"int"];

    [defaults setBool:YES forKey:@"auto_login"];

    [defaults synchronize];

    

    [defaults objectForKey:@"name"];

    [defaults integerForKey:@"int"]; 

iOS Plist NSUserDefaults 数据存储

标签:

原文地址:http://www.cnblogs.com/hanjian/p/4450267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!