快速生成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];

 

posted @ 2015-08-04 22:06  heyuan123  阅读(641)  评论(0编辑  收藏  举报