zoukankan      html  css  js  c++  java
  • 快速生成plist文件

    在一个项目中,我们会经常用到许多plist文件,但是你怎么快速生成plist 文件吗?我给你提供一个方法。

     NSArray *title = [[NSArray alloc]initWithObjects:@"限免",@"降价",@"免费",@"专题",@"热榜", nil];

        NSArray *iconName= [[NSArray alloc] initWithObjects:@"tabbar_limitfree",@"tabbar_reduceprice",@"tabbar_appfree",@"tabbar_subject",@"tabbar_rank" ,nil];

        NSArray *className = [[NSArray alloc] initWithObjects:@"LViewController",@"RViewController",@"FViewController",@"SViewController",@"HViewController", nil];

       

        

        NSMutableArray *all = [[NSMutableArray alloc]initWithCapacity:0];

        

        for (int i = 0; i<title.count; i++) {

            //以键值对的方法 生成一个字典

            NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:[title objectAtIndex:i],@"title",[iconName objectAtIndex:i],@"iconName",[className objectAtIndex:i],@"className", nil];

            [all addObject:dict];

        }

        //NSString *tempPath = NSTemporaryDirectory();

        NSString *tempPath= @"/Users/Desktop/";

        NSString *path = [tempPath stringByAppendingPathComponent:@"Controllers.plist"];

        NSLog(@"%@",path);

        [all writeToFile:path atomically:YES];

  • 相关阅读:
    1112评论汇总
    二叉树前序中序后续(递归和非递归遍历)
    leetcode Best Time to Buy and Sell Stock III
    JNI(Java本地方法调用)
    中文分词工具介绍
    指针的引用
    Java变量方法初始化顺序
    Java数组与列表转换的java.lang.ClassCastException
    字符串或者数字数组全排列
    Hbase基本命令
  • 原文地址:https://www.cnblogs.com/PengFei-N/p/4703281.html
Copyright © 2011-2022 走看看