属性列表的使用方法

来源:互联网 发布:正规网络兼职药师招聘 编辑:程序博客网 时间:2024/05/16 16:01

1.创建一个iOS->Resource->Property List的属性列表

2.#pragma mark===================解析属性文件数据
    
  /*  //获取文件路径
    NSString *path = [[NSBundle mainBundle] pathForResource:@"StudentInformation" ofType:@"plist"];
    
    //获取数据
    NSArray *array = [NSArray arrayWithContentsOfFile:path];
    
    _studentsArray = [NSMutableArray arrayWithCapacity:3];
    
    //封装模型
    for(NSDictionary *dict in array)
    {
       //创建一个学生对象
        Student *student = [Student new];
        
        //将字典赋值给学生属性
        [student setValuesForKeysWithDictionary:dict];
        
        
        //NSLog(@"%@",student);
        
        [_studentsArray addObject:student];
    }
    
    for (Student *student in _studentsArray) {
        
        NSLog(@"%@",student);
    }
   
 */
   

//注意:属性列表中只能添加数组和字典两种数据,有很大的局限性,使用范围很少.

0 0