WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

How to save an audio file using Core Data + CloudKit?

Forums > iOS

I am transitioning to using CloudKit for syncing, using NSPersistentCloudKitContainer to manage syncing. In my app you can record audio, and I've been saving that by saving the file to disc and storing a relative URL to Core Data.

How can I get this to work using NSPersistentCloudKitContainer? I read that I shouldn't store large data as a CoreData attribute for performance, but I need the data to sync with CloudKit.

Thanks!

3      

To save an audio file using Core Data + CloudKit:

  1. Prepare your Core Data model with an entity for audio recordings.
  2. Save the audio file locally and obtain its URL.
  3. Store the audio file URL in Core Data along with metadata.
  4. Use Core Data to sync metadata with CloudKit. CloudKit won't sync the audio file itself, so you'll need to manage file storage separately, possibly using iCloud Drive or another cloud service.

3      

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.