I use SBJsonParser for parsing a large json response I query from a server. I'd like to use a timestamp approach to know when I actually have to re-obtain and re-parse all the data again, so I'd like to know how I can save my data for those times I don't need to request the large JSON package to refresh my data.
I'm thinking I should be using the NSCoding protocol and archiving roughly like the following:
// alloc nsdata obj
NSMutableData *data = [[[NSMutableData alloc] init] autorelease];
// create archiver
NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:data] autorelease];
// archive whiteboard
[archiver encodeObject:mSaveData forKey:@"Data"];
[archiver finishEncoding];
[data writeToFile:dataPath atomically:YES];
but is there a simple way to encode this JSON object that is really an NSArray of NSDictionaries, or do I have to meticulously encode each field within this object?
Maybe there is a simpler way altogether, like saving the json object itself as a string (before it is parsed with the objectWithData method) and re-parsing it each time the app loads and wants to use the local copy?