I recently decided to make my move to StackMob (from Parse). I have managed to setup core data and i can read and write to StackMob datastore.
So far, StackMob offers a list of item to the user. If the user decides to user an item on my app, I want the item to be available offline, so he can use it without having to connect to stackmob.
I am thinking of creating a local Core Data and copying the items that the user select there. My first problem is if i could use the same object for both Core Data (stackmob and local). And if this is the right approach to follow.
The latest sdk includes support for caching of core data. Details are In this blog post.
The caching system is off by default. To turn it on, simply set the SM_CACHE_ENABLED flag to YES in your App Delegate file, before you initialize a Core Data store. The flag is declared in SMCoreDataStore.h.
It also includes this code example for how to control the cache...
SMClient *client = [[SMClient alloc] initWithAPIVersion:@"0" publicKey:@"XXXX"];
SMCoreDataStore *coreDataStore = [client coreDataStoreWithManagedObjectModel:myModel];
[client.session.networkMonitor setNetworkStatusChangeBlockWithCachePolicyReturn:^SMCachePolicy(SMNetworkStatus status) {
if (status == Reachable) {
return SMCachePolicyTryNetworkElseCache;
} else {
return SMCachePolicyTryCacheOnly;
}
}];