QQ Friends in more information, if we separate from the plist directly remove the data is to solve the problem
But it's quite complicated to think of groups in the list, with different information in each group.
The approximate model is a set of arrays of array array arrays dictionary
So we're going to encapsulate the data model
gpgroupcontroller.h// 02-Friends Group//#import <UIKit/UIKit.h> @interface Gpgroupcontroller: Uiviewcontroller@end
gpgroupcontroller.m//02-Friends Group//#import "GPGroupController.h" #import "GPGroup.h" #import "Nsarray+localprint.h" @ Interface Gpgroupcontroller () @property (Nonatomic,strong) Nsarray *groups; @end @implementation gpgroupcontroller-( Nsarray *) groups{if (_groups = = nil) {//1. NSString *path = [[NSBundle mainbundle]pathforresource:@ "Qq_group.plist" oftype:nil]; Nsarray * dicts =[nsarray Arraywithcontentsoffile:path]; 2. Nsmutablearray *OBJS = [Nsmutablearray array]; For (Nsdictionary *dic in dicts) {Gpgroup *group = [Gpgroup groupwthdict:dic]; [Objs Addobject:group]; }//3. _groups = OBJS; } return _groups;} -(void) viewdidload {[Super viewdidload]; NSLog (@ "%@", self.groups); Do any additional setup after loading the view.} -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before navigation-(void) preparefor Segue: (uistoryboardsegue *) Segue sender: (ID) Sender {//Get the new view controller using [Segue Destinationviewcontrol Ler]. Pass the selected object to the new view Controller.} */@end
gpfriend.h// 02-Friends Group #import <Foundation/Foundation.h> @interface Gpfriend:nsobject@property ( nonatomic,copy) NSString *icon; @property (nonatomic,copy) nsstring *message; @property (nonatomic,copy) NSString *name; + (ID) friendwithdict: (Nsdictionary *) dict;-(ID) initwithdict: (Nsdictionary *) dict; @end
gpfriend.m// 02-Friends Group//#import "GPFriend.h" @implementation gpfriend+ (ID) friendwithdict: (nsdictionary *) dict{ return [[Self alloc]initwithdict:dict];} -(ID) initwithdict: (nsdictionary *) dict{ if (self = [super init]) { [self setvaluesforkeyswithdictionary:dict] ; } return self;} -(NSString *) description{ return [nsstring stringwithformat:@ "icon=%@,name=%@,message=%@", _icon,_name,_ Message];} @end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
QQ Buddy list data Model encapsulation