Core Data: Beyond the Basics

Jul 26 2022 · Swift 5.5, iOS 15, Xcode 13.3.1

Part 2: Advanced Core Data

19. Storing Large Files

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 18. Deleting Launch Lists Next episode: 20. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

So far, everything you’ve modeled in your entities have been primitive data types - Ints, Strings, Dates and Booleans. What if you wanted to model data that didn’t fit into one of these categories? What about media such as audio, video or an image? Can Core Data handle this? It most certainly can.

import UIKit
@NSManaged public var attachment: UIImage?
@State var attachment: UIImage?
.sheet(isPresented: $showImagePicker) {
	ImagePicker(selectedImage: $attachment)
}
launchpad: self.launchpad,
attachment: self.attachment,
tags: tags,
if let attachment = attachment {
	Image(uiImage: attachment)
	  .resizable()
	  .aspectRatio(contentMode: .fit)
} else {
	Button("Pick Image") {
	  showImagePicker.toggle()
	}
}
launchpad: String,
attachment: UIImage?,
tags: Set<Tag> = [],
    
//.....

launch.attachment = attachment
@NSManaged public var attachment: Data?
launch.attachment = attachment?.jpegData(compressionQuality: 1) ?? Data()