NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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!

   

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.

   

Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

Sponsor Hacking with Swift and reach the world's largest Swift community!

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.