How does one use CoreData on tvOS? There's no persistent local storage, but there's no UI(Managed)Document either. Can I place my CD persistent stores in CloudKit somehow? Surely not Key-Value storage?
Core Data
You able to use CoreData, but be aware that the database might go away at anytime. Here's the tvOS programming guide on iCloud storage.
For truly persistent storage, you can utilize CloudKit for your structured data.
CoreData is included to allow for data and object graphs locally in a cache or temporary scenario. But it would not be appropriate to use it for persistent storage on tvOS.
Is there really no way to place CD persistent stores in CloudKit or is CD on tvOS actually not useful for any real work whatsoever? Surely users are not expected to be content in the sporadic loss of all game progress and other data just because of the format in which it is stored?
Do I need to a) cancel any further attempt to bring my existing iOS software, heavily reliant on Core Data, onto the tvOS platform, or
b) do vast amounts of useless work on boilerplate code to manually backup/restore, on each program run, all CD context data from/to whatever formats are in fact supported by CloudKit, if any?
The recommended path would be to make use of CloudKit for your data persistence if the 1MB of iCloud KVS will not be sufficient.
Thank you for your interest in developing for the platform, and I appreciate that this does likely require a lot of re-working of your approach to persisting data to the device. We would ask that you file an enhancement request at bugreporter.apple.com describing in detail how your application works and why the existing functionality will not support bringing your application to tvOS.
Well, I already looked into backing up my NSPersistentStore into a singleton Cloudkit db as a CKAsset instance, and restoring it from there whenever necessary. Perhaps it won't be that hard. Just waiting for my development kit to arrive, since iCloud functionality can't seem to be enabled at all without an actual development device on hand.
UIManagedDocument would, of cource, make a nice enhancement to the platform.
It's lame that Core Data databases aren't supported. But here's how you can limp along during your potentially painful migration to CloudKit:
#if TARGET_OS_TV
NSString *storeType = NSInMemoryStoreType;
#else
NSString *storeType = NSSQLiteStoreType;
#endif
if (![_persistentStoreCoordinator addPersistentStoreWithType:storeType configuration:nil URL:storeURL options:options error:&error]) {
...
}