//加载plist: plist -> 数组(dictArray) if (1) { NSArray *dictArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"questions" ofType:@"plist"]]; //将plist中的数据加载到数组Array中 //NSLog(@"%@",dictArray); //字典转换模型 //NSMutableArray *questionArray = [NSMutableArray array]; NSMutableArray *questionArray = [[NSMutableArray alloc]init];//先创建一个可变数组questionArray NSLog(@"%@",questionArray); //遍历数组: for (NSDictionary *dic in dictArray)//遍历:将数组dictArray中的数据存储到字典dic中去 { // NSLog(@"dicArray = %@",dictArray); // NSLog(@"dic1 = %@"); //GQuestions *question = [GQuestions questionWithDict:dic];//新建一个GQuestion类型的question指针指向dic,并且循环一次以后dict就会变化, question中存储的地址也会跟着变化 // NSLog(@"question = %@",question); // NSLog(@"dic2 = %@"); [questionArray addObject:[GQuestions questionWithDict:dic]];//在数组questionArray的最后添加question信息 // NSLog(@"questionArray = %@",questionArray); } _questions = questionArray;
原文:http://www.cnblogs.com/cubeTC/p/3631914.html