Archive:
Nsmutabledata *data = [[Nsmutabledata alloc] init];
Create an Archive helper class
Nskeyedarchiver *archiver = [[Nskeyedarchiver alloc] initforwritingwithmutabledata:data];
Coding
[Archiver encodeobject:@ "2009-12-09" forkey:@ "Datatime"];
End encoding
[Archiver finishencoding];
Write
[Data writetofile:[self getfilepathwithmodelkey:[nsstring stringwithformat:@ "test"] atomically:yes];
Method://Get Document Directory
-(NSString *) Getfilepathwithmodelkey: (NSString *) Modelkey
{
Nsarray *array = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
return [[Array objectatindex:0] stringbyappendingpathcomponent:modelkey];
}
Solution file:
NSData * data = [[NSData alloc] initwithcontentsoffile:[self getfilepathwithmodelkey:[nsstring stringwithformat:@ "test "]]];
Solution Auxiliary Class
Nskeyedunarchiver *unarchiver = [[Nskeyedunarchiver alloc] initforreadingwithdata:data];
NSString * time = [Unarchiver decodeobjectforkey:@ "Datatime"];
Close the solution
[Unarchiver finishdecoding];
IOS Archive Solution