美文网首页
plist文件的相关操作

plist文件的相关操作

作者: 走道牙的人 | 来源:发表于2016-07-18 16:05 被阅读22次
    // 加载plist文件
    NSString *path = [[NSBundle mainBundle]pathForResource:@Property List ofType:@plist];
    NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithContentsOfFile: path];
    
    //获取应用沙盒的Douch
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
    NSString *plist1 = [paths objectAtIndex:0];
    
    //获取一个plist文件
    NSString *filename = [plist1 stringByAppendingString:@test.plist];
    [data writeToFile:filename atomically:YES];
    NSMutableDictionary *data1 = [[NSMutableDictionary alloc]initWithContentsOfFile:filename];
    //打印出字典里的数据
    NSLog(@%@,data1);
    
    //修改一个plist文件的数据
    [data1 setObject:@要修改的数值 forKey:@要修改的name];
    [data1 writeToFile:filename atomically:YES];
    

    相关文章

      网友评论

          本文标题:plist文件的相关操作

          本文链接:https://www.haomeiwen.com/subject/fanpjttx.html