zoukankan      html  css  js  c++  java
  • ios--plist

    //
    //  main.m
    //  03-plist文件的回顾
    //
    //  Created by xiaomage on 15/12/29.
    //  Copyright © 2015年 小码哥. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    
    int main(int argc, const char * argv[]) {
        @autoreleasepool {
           // 数组
            NSArray *names1 = @[@"yjh", @"gxq", @"mj", @"nj"];
            BOOL flag1 = [names1 writeToFile:@"/test.plist" atomically:YES];
            
            NSDictionary *persons2 = @{
                                      @"name" : @"yjh",
                                      @"age" : @18,
                                      @"height" : @1.88
                                      };
            BOOL flag2 = [persons2 writeToFile:@"/Users/mctc/Desktop/a.plist" atomically:YES];
            
            NSArray *persons3 = @[
                                 @{@"name" : @"mj", @"age":@38},
                                 @{@"name" : @"yjh", @"age":@25, @"friends":@[@"大神11期", @"sz"]}
                                 ];
            BOOL flag3 = [persons3 writeToFile:@"/Users/mctc/Desktop/a.plist" atomically:YES];
            if (flag3) {
                NSLog(@"写入成功!");
            }
            
            
            NSArray *dataArr4 = @[
                             @{@"name":@"单肩包", @"icon":@"danjianbao"},
                             @{@"name":@"钱包", @"icon":@"qianbao"},
                             @{@"name":@"链条包", @"icon":@"liantiaobao"},
                             @{@"name":@"手提包", @"icon":@"shoutibao"},
                             @{@"name":@"双肩包", @"icon":@"shuangjianbao"},
                             @{@"name":@"斜挎包", @"icon":@"xiekuabao"}
                             ];
            BOOL flag4 = [dataArr4 writeToFile:@"/Users/mctc/Desktop/a.plist" atomically:YES];
            if (flag4) {
                NSLog(@"写入成功!");
            }
           
            NSArray *persons5 = [NSArray arrayWithContentsOfFile:@"/Users/mctc/Desktop/a.plist"];
            NSLog(@"%@", persons5);
            /*
             (
             {
             icon = danjianbao;
             name = "U5355U80a9U5305";
             },
             {
             icon = qianbao;
             name = "U94b1U5305";
             },
             {
             icon = liantiaobao;
             name = "U94feU6761U5305";
             },
             {
             icon = shoutibao;
             name = "U624bU63d0U5305";
             },
             {
             icon = shuangjianbao;
             name = "U53ccU80a9U5305";
             },
             {
             icon = xiekuabao;
             name = "U659cU630eU5305";
             }
             )
             */
        }
        return 0;
    }
  • 相关阅读:
    解决ie下vue列表数据不能即时刷新的问题
    redis的几个知识点
    oracle查找某个字符在字符串中的个数的技巧
    程序员必看书籍
    eclipse彻底去除validation(彻底解决编辑js文件的卡顿问题)
    eclipse强行停止buliding workspace
    [Ljava.lang.String是一个字符串数组的字节码表示
    javascript合并两个数组
    css隐藏页面元素的方法
    配置IIS使用Python
  • 原文地址:https://www.cnblogs.com/yaowen/p/7449649.html
Copyright © 2011-2022 走看看