StackMob local storage datastore

I recently decided to make my transition to StackMob (from Parse). I was able to set up the basic data and I can read and write to the StackMob store.

For now, StackMob offers a list of items for the user. If the user decides to use an item in my application, I want the item to be available offline, so he can use it without connecting to the stackmob.

I'm going to create local kernel data and copy the items the user selects there. My first problem is that I can use the same object for Core Data (stackmob and local). And if that's the right approach to follow.

+3


source to share


1 answer


The latest version of the sdk includes support for caching master data. Details in this blog .

By default, the caching system is disabled. To enable it, simply set the SM_CACHE_ENABLED flag to YES in the application delegate file before initializing the master data store. The flag is declared in SMCoreDataStore.h.



It also includes this sample code for managing 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;
        }
}];

      

+2


source







All Articles