zoukankan      html  css  js  c++  java
  • 对plist文件的简单封装

    常常会用到对plist文件的封装,毕竟初学者,多记有经验

    +(NSArray *)LoadFriendsDataFromPlist:(NSString *)pliatName{

        NSString * filePath = [[NSBundle mainBundle]pathForResource:pliatName ofType:@"plist"];

        NSArray * array = [NSArray arrayWithContentsOfFile:filePath];

        NSMutableArray * dataArray = [NSMutableArray array];

        

        for (NSDictionary * dic in array) {

            //读取分组名

            NSString * groupName = [dic objectForKey:@"groupName"];

            //读取好友

            NSArray * friendArray =[dic objectForKey:@"friends"];

            //封装好友为

            NSMutableArray * personArray = [NSMutableArray array];

            for (NSDictionary * dic in friendArray) {

                Person * person = [[Person alloc]initWithName:[dic objectForKey:@"name"] iconName:[dic objectForKey:@"icon"] introduction:[dic objectForKey:@"intro"]];

                [personArray addObject:person];

            }

            NSDictionary * groupDic = @{@"friends":personArray,@"groupName":groupName};

            [dataArray addObject:groupDic];

        }

        return dataArray;

    }

  • 相关阅读:
    nginx内置高可用配置与第三方高可用模块nginx_ustream_check_mudule配置
    nginx+php,nginx+tomcat动静分离实战
    面向对象三大特性之多态与多态性
    面向对象三大特性之组合
    面向对象三大特性之继承与派生
    面向对象编程初探
    常用模块
    模块
    函数
    文件处理
  • 原文地址:https://www.cnblogs.com/huoran1120/p/5232368.html
Copyright © 2011-2022 走看看