Reputation: 1
My initial in-app purchases were included in the Main Bundle, formatted as Core Data/Sqlite files. Now I want Apple to host all further IAPs. So far I’ve done the setup in iTunes connect, successfully downloaded the files and moved them from the cache to the Application Support Directory.:
if ([fileManager moveItemAtPath:fullPathSrc toPath:fullPathDst error:&error] == NO) {
NSLog(@"Error: unable to move item: %@", error);
}
At this point the source path is:
/private/var/mobile/Containers/Data/Application/54EBE737-AB3C-414D-ABE6-C472469431EF/Library/Caches/7AAD2581-5933-4ACF-BE5D-2F7FB134F914.zip/Contents/Packet5.sqlite
and the destination path is:
/var/mobile/Containers/Data/Application/54EBE737-AB3C-414D-ABE6-C472469431EF/Library/Application Support/Downloads/Packet5.sqlite
Looking good until my Core Data class tries to access a sqlite file, as follows:
NSURL *modelURL = [NSURL fileURLWithPath:(NSString *)packetLocator[currPacketNum]];
// packetLocator[currPacketNum] contains the destination path above.
Then I get the following error message:
CoreData: Failed to load keyed archive model at path '/var/mobile/Containers/Data/Application/54EBE737-AB3C-414D-ABE6-C472469431EF/Library/Application Support/Downloads/Packet5.sqlite'
Perhaps there's a global problem; i.e., Is it even possible to host Core Data with Apple? Has anyone successfully hosted Core Data, or know of a workaround to this problem?
Upvotes: 0
Views: 120
Reputation: 1
I was confusing 2 different types of core data files, the “momd” data model file which describes relationships between data items, with the sqlite/json core data files themselves. There is only one “momd” file per configuration - it cannot change during execution, and it lives in the Main Bundle. I was retrieving the model file as if it were a core data file - oops!
Upvotes: 0