Re: Restkit offline core data save, can't retrieve

57 views
Skip to first unread message
Message has been deleted

Matt

unread,
May 21, 2013, 4:55:59 PM5/21/13
to res...@googlegroups.com
You can all ignore this...it was a case of Hurp-a-Durp-itz.  My friggin fetch query was wrong because I didn't default a column to a value so it didn't pick up the new values in the DB.

On Tuesday, May 21, 2013 10:46:57 AM UTC-4, Matt wrote:
Ok so I have an application that uses core data to save while in offline mode.  I can successfully push the data down to the database, however it seems that when I go to execute a fetch, none of the new data is there.

Is this some kind of caching issue?

Here is my restkit initialization methods


- (void) initializeRestKit

{

   // Retrieve the base server URL

   NSString* serverName = [[Resource_Service sharedModel] getDictValue:@"ServerName"];


   


    // RKObjectManager is our base class for any requests that involove mapping to core data


    self.RestKitObjectManager = [[RKObjectManager sharedManager] init];


    self.RestKitObjectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:serverName]];


   


    // Enable automatic network activity indicator management


    [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;


   


    // Configure MIME Types


    self.RestKitObjectManager.requestSerializationMIMEType = RKMIMETypeJSON;


   


    // Configure the core data


    [self configureCoreData];


   


    // Add the routing paths


    [self addRoutingPaths];


   


    // Wire up any observers for the data


    [self wireUpObservers];


}




- (void) configureCoreData


{


    // Retrieve the model name


    NSString* momdName = [[Resource_Service sharedModel] getDictValue:@"ManagedObjectModelName"];


 


    // Retrieve the base SQL file Name


    NSString* sqlFileName = [RKApplicationDataDirectory() stringByAppendingPathComponent:[[Resource_Service sharedModel] getDictValue:@"DataStoreFileName"]];


   


    // Retrieve the model URL


    NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:momdName ofType:@"momd"]];


   


    self.RestKitManagedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy];


    self.RestKitObjectStore = nil;


    self.RestKitObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:self.RestKitManagedObjectModel];


    [self.RestKitObjectStore addSQLitePersistentStoreAtPath:sqlFileName fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:nil];    


   


    // Create the managed object contexts


    [self.RestKitObjectStore createManagedObjectContexts];


    self.RestKitObjectManager.managedObjectStore = self.RestKitObjectStore;


   


    // Configure a managed object cache to ensure we do not create duplicate objects


    self.RestKitObjectManager.managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:self.RestKitObjectManager.managedObjectStore.persistentStoreManagedObjectContext];


}



Reply all
Reply to author
Forward
0 new messages