I'm trying to load the NSData from my Core Data database but the data isn't even remotely close to what's displaying if I compare the two files, the original database vs the one saved from the NSData loaded, and the one saved from the NSData doesn't have any data in it at all, only the table structure.
Here's my source, and it's extremely basic:
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
if (managedObjectContext != nil) {
NSError *error = nil;
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
NSString *path = [AppDelegate instance].databaseDirectory.path;
NSData *file = [[NSFileManager defaultManager] contentsAtPath:path];
[file writeToFile:[AppDelegate instance].tempDatabaseDirectory.path atomically:NO];
Aucun commentaire:
Enregistrer un commentaire