Sharing/Invite CoreData iCloud documents with others - ios

With with my coreData file syncing to iCloud, can I send a link to that file or an invite to a friend (who has a different iCloud account) so we can share that info through the app?

No, you cannot do that. iCloud does not allow direct file sharing links like Dropbox.
Also, you should not be directly syncing a CoreData sqlite file. CoreData has its own syncing mechanism for iCloud, and you should not sync it as a whole file. From Apple's documentation:
You cannot simply move or copy an existing database file to iCloud.
Instead, you should use NSPersistentStoreCoordinator's
migratePersistentStore:toURL:options:withType:error: method to migrate
the database to the required location.
http://developer.apple.com/library/ios/#releasenotes/DataManagement/RN-iCloudCoreData/index.html

Related

Save user defaults to iCloud

I don't have any important data in my app. But when i read this tutorial i have a few questions ?
Only documents and other data that is user-generated, or that cannot
otherwise be recreated by your application, should be stored in the
/Documents directory and will be automatically
backed up by iCloud.
Do i need to save UserDefaults to iCloud ? And will my app approve if i don't use iCloud ?
And if i need can you show me how to save user default settings ? Because i found only tutorials how to save data from database.
You misunderstand what that is saying.
When a user backup's up their devices using iTunes or iCloud, only certain parts of the app's sandbox is backed up. So there are two important aspects here:
Only backup data that can't be replaced.
Be sure to backup irreplaceable data.
NSUserDefaults is one of the things that will be backed up for you. You don't need to do anything special.
You don't need iCloud support unless your app has a specific need to use it.

iCloud setting like clear app in ios

I have tried many iCloud example but I want to migrate iCloud to local and local to iCloud without duplication like in Clear app in ios. I have tried this example too
iCloudStoreManager
Can You please help me to solve it.
You can try the following:
If the user wants to keep the cloud data, delete the local store before creating the persistent store with iCloud settings turned on. iCloud should then populate your local store with the data from the cloud automatically.
If the user wants to keep the local data, migrate the existing local store to a new temporary store with no iCloud settings, then use the NSPersistentStoreCoordinator method
+removeUbiquitousContentAndPersistentStoreAtURL:error: to remove the existing iCloud data. Finally, migrate the temporary store back with iCloud settings turned on. You should end up with only the data from the temporary store.
Another option is to not remove any data at all, but deduplicate data as mentioned by Tom Harrington.
Lastly, you might have more luck with the Ensembles open source framework. It works with iCloud, but — being an open source project — is more transparent than Apple's solution, and generally easier to get up and running. (Disclosure: I am a developer of Ensembles)

iCloud sync files and core data

In my app I save images in file manager and their metadata(image name,created date,notes and image path) in core data.
I want to know the best practice to sync these data using iCloud.
If you save the images in the ubiquity container they will be synchronised across devices. However you may need to store a relative pathname rather than an absolute pathname.
If you take a look at the the sample apps at the link below you will find the app uses iCloud to synchronise the Core Data database using transaction logs and it uses iCloud to synchronise the backup files the user makes. So while this is not exactly what you want it would be pretty easy to modify the code for saving the backup files to iCloud to save your files to iCloud.
You do need to remember that iOS will not automatically download files from iCloud so you would have to do that from your App prior to trying to use them on the device.
http://ossh.com.au/design-and-technology/software-development/

local core data store with icloud

I have a question regarding icloud store with core data store in iOS7. In the apple WWDC conference, it was mentioned that the core data store can be created in the sandbox and when the app starts receiving responses from icloud, the changes in the core data store will be merged into icloud store.
Now, (I might be wrong), but the conference further mentioned that the local core data store would be deleted once the app has switched over to the icloud store. So, my question is can a local core data store co-exist with the icloud store in iOS7 (so that the user has capability to work offline with data) ? And is there any sample code for this ?
In iOS 7, the Core Data framework takes care of managing the local store until the iCloud store is setup and available. This pattern also works for when the app is offline and it doesn't delete any data when the app goes offline (just double checked on my app in development).
The iCloud store will be deleted in another case. That's in the event the iCloud user account changes in which case the respective iCloud store file will be removed. In such case, there is a new API NSPersistentStoreCoordinatorStoresWillChangeNotification that allows you to store unsaved data before the store becomes unavailable. If the user logs in later with that same account, the data will be restored from iCloud (check the WWDC 2013 session 207 video at 15' for more on this).
As for sample code, there isn't any as of today. There is, though, iCloud sample code shared by AppleSpaceMan on the developer forum, which is what I used as a base and worked nicely.
You can work offline(no network connection) with the iCloud store as long as you have an iCloud account and are logged in to that account. I have just posted a sample application that includes the following features:
Use of Local or iCloud Core Data store
Includes a Settings Bundle (note that this creates a settings page in the Settings App) that includes:
Use iCloud preference setting (ON or OFF)
Make Backup preference setting (ON or OFF)
Display application Version and Build Number
Prompts the user about storage options when the Use iCloud preference is changed to ON
Migrates Core Data store to and from iCloud depending on the users preference setting and response to prompts
Detects deletion of iCloud store from another device and cleans up by creating a new empty iCloud store
Checks for existing iCloud files when migrating local store to iCloud and prompts user whether to merge or discard data in local store if an iCloud file exists
Makes a Backup of the Core Data store if Make Backup preference is set to ON.  Backup file name is persistentStore_Backup_yyyy_MM_dd_HH_mm_ss. To use it:
set Backup preference ON and next time the app is activated it will make a backup of the current Core Data store and reset the preference to OFF
file can be copied to PC or Mac from iTunes
to restore simply set app to use Local files (Use iCloud preference OFF) and replace the persistentStore file with the required backup file (note the file must be called persistentStore).
to then share restored file via iCloud again turn Use iCloud preference to ON and run App
http://ossh.com.au/design-and-technology/software-development/sample-library-style-ios-core-data-app-with-icloud-integration/

iCloud data sharing to all app users

I wanted to know if icloud could be used as a file sharing database for your application amongst all app users or not. If for example in my app you can save a file on icloud, can anyone who uses my app download it or only the person who has uploaded it??
Using iCloud there are no sharing options - only the user who uploaded data can access it.

Resources