Storing the data of the custom class directly into the Nsuserdefaults as an array is an error, needs to be converted, and the class needs to implement the Nscoding protocol.
e.g.
Stored Procedures
Nsmutablearray *archivearr = [Nsmutablearray arraywithcapacity:self. Stnarraylist.count];
for inch Self . stnarraylist) { *listencodedobject = [Nskeyedarchiver archiveddatawithrootobject:singlelist]; [Archivearr addobject:listencodedobject]; } // Archivearr can be stored in nsuserdefaults.
Read process
Nsarray *localsavedarr =; // to read locally stored data from Nsuserdefaults Nsmutablearray *mutablearr = [Nsmutablearray arrayWithCapacity:localSavedArr.count]; for inch Localsavedarr) { *singlelist = [Nskeyedunarchiver unarchiveobjectwithdata:data]; [Mutablearr addobject:singlelist]; } // you can now access Mutablearr to get the value of Stnarraylist
Implementing the Nscoding protocol in the Stnarraylist class
-(ID) Initwithcoder: (Nscoder *) adecoder{ if (self = = [Super init]) {= [Adecoder Decodeobjectforkey:json_key]; } return Self ;} -(void) Encodewithcoder: (Nscoder *) acoder{ [Acoder encodeobject:_title forkey:json_key];}
Storing data for custom types in Nsuserdefaults