Here, convert the dictionary to the NSData type. One thing to be aware of, must be achieved
-(ID) Initwithcoder: (nscoder *) Adecoder method and
-(void) Encodewithcoder: (nscoder *) Acoder method.
+ (nsdata *) returndatawithdictionary: (nsdictionary*) dict
{
nsmutabledata* data = [[nsmutabledata alloc]init];
nskeyedarchiver* archiver = [[nskeyedarchiver alloc] Initforwritingwithmutabledata:d ATA];
[Archiver encodeobject:d ICT forkey:@ "Talkdata"];
[Archiver finishencoding];
return data;
}
Convert a string from a dictionary path to a dictionary
+ (nsdictionary *) Returndictionarywithdatapath: (nsstring*) path
{
nsdata* data = [[nsmutabledata alloc]initwithcontentsoffile:p ath];
nskeyedunarchiver* unarchiver = [[nskeyedunarchiver alloc]initforreadingwithdata: Data];
nsdictionary* mydictionary = [unarchiver decodeobjectforkey:@ "Talkdata"];
[Unarchiver finishdecoding];
return mydictionary;
}
Conversion of Ios-nsdata and nsdictionary to each other