TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.