I get an array (containing text) called titleArray from json which I populate a uitableview with. I would like to cache it in memory so that data for the screen loads once, it will not need to load again per session. I’ve never done this..
basically I have 2 methods:
- (void)requestFinishedWithResult:(NSDictionary*)result
- (void)requestFailed
depending on if I get anything from the server.
Somewhere in the - (void)requestFinishedWithResult:(NSDictionary*)result I’m thinking I need an additional array to store the titleArray data in…and then do something like this: ??
-(void)requestFailed
{
if (titleArray != nil)
{
storeArray = titleArray;
}
}
or something like that? but I really don’t know how it should work. Any help is appreciated.
Depends on what kind of persistance you want. You can store it on the disk and then load it and have a mechanism to update that cached data. Or, you can just store on an ivar and retain it’s value, this way you will have the data for the duration of the application.