objective c - Storing NSMutableArray of UIViews in NSUserDefaults -
i have read several posts i'm not able fix error. if please help.
here code use. have nsmutablearray called list.
-(void) awakefromnib { prefs=[[nsuserdefaults standarduserdefaults]retain]; if ([prefs arrayforkey:@"list"]) { list=[[nsmutablearray alloc]initwitharray:[prefs objectforkey:@"list"]]; } else { list=[[nsmutablearray alloc]init]; } } -(void)savedata { nslog(@"saving data!"); [prefs setobject:list forkey:@"list"]; } - (void)dealloc { [self savedata]; [prefs synchronize]; [prefs release]; }
you cannot store uiview instances in user defaults, objects can serialized in property list (see here) also, @justin said, not retain or release defaults object.
Comments
Post a Comment