UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.