IOS app with basic data, photos and iCloud

I am developing an application that uses basic data (with UIManagedDocument) to store user data that I would like to sync with iCloud. I would also like to synchronize the photos that the user takes with the camera in the application.

I read that it is not recommended to store actual photos in the master data; rather, it is better to save the photos in the file system and put the URL file in the master data.

Using this method, is it recommended to use UIDocument to store photos on the file system (in the Documents folder)? I'm thinking of:

  • For each individual photo, use NSFileWrapper (containing the actual image and thumbnail), or
  • Use the top level NSFileWrapper and put all the NSFileWrappers for each photo in it.
  • Like # 2, but just put all the photos / thumbnails directly in the top level NSFileWrapper

Which approach is better for syncing photos with iCloud? and are there any better approaches?

+4
source share
1 answer

The best approach in this case is to let Core Data decide where to put it.

Open the GUI of the Core Data model - click on your attribute that will contain your binary data - look to the right - there is a flag indicating whether to use Core Data to use external storage. Choose it.

It's all. If Core Data needs to use external storage, it will do it - you don't know and don't care what it solves.

+5
source

Source: https://habr.com/ru/post/1434370/


All Articles