博客> 本地存取
本地存取
2017-11-23 14:09 评论:0 阅读:137 飞翔信念
ios 登录 tabbar

今天一哥们问我本地存储,脑袋不好使,记不住代码,记录下直接能用的。

    //存入本地
     NSMutableArray * arrayOne=[[NSMutableArray alloc]init];
    [arrayOne addObjectsFromArray:_userArray];
    NSArray *doc = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *docPath = [ doc objectAtIndex:0 ];
     NSString *multiHomePath=[docPath                             stringByAppendingPathComponent:@"bookmark.plist"];
    [arrayOne writeToFile:multiHomePath atomically:YES];

    //从本地获取到数组
    NSArray *doc = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *docPath = [ doc objectAtIndex:0 ];
    NSString *multiHomePath=[docPath                             stringByAppendingPathComponent:@"bookmark.plist"];
    NSMutableArray * areaArray=[NSMutableArray arrayWithContentsOfFile:multiHomePath];
收藏
0
sina weixin mail 回到顶部