NSMutableArray in NSUserDefault -


i've problem table!

i use parsing tableview when change view, table loses data. decide save data nsuserdefault; but, here problem, nsuserdefault warns me: "note dictionaries , arrays in property lists must contain property values."

nb: itemstodisplay nsmutablearray , contain title, url, data , summary of parseditems.

well, here code:

self.itemstodisplay = [[[nsuserdefaults standarduserdefaults] arrayforkey:@"items"] mutablecopy];  if (!self.itemstodisplay) {     self.itemstodisplay = [[nsmutablearray alloc] init]; }  self.itemstodisplay = [[nsmutablearray alloc]init];  self.itemstodisplay = [parseditems sortedarrayusingdescriptors:                        [nsarray arraywithobject:[[[nssortdescriptor alloc] initwithkey:@"date"                                                                              ascending:no] autorelease]]];   [[nsuserdefaults standarduserdefaults] setobject:self.itemstodisplay forkey:@"items"]; [[nsuserdefaults standarduserdefaults] synchronize]; 

i suppose problem setobject:self.itemstodisplay, don't know how solve it.

thank guys..

first lets mention table cannot lose data because not hold user data. data either provided through bindings or through delegation see nstableviewdatasource in apples documentation).

second, first 3 assignments self.itemstodisplay serve no purpose (unless have side-effects in setter) because overridden last assignment.

finally, if code in delegate delegate should instantiated in nib file data survive past view swap. if delegate object instantiated view die along of data , writing user-defaults bad idea trying achieve. set delegate object lifetime greater of both views.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -