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

Uploading Image from Image Picker, Saving it with core data, and displaying it as a navigation link in content view

Forums > SwiftUI

Is it possible I can recieve some sample code of an image picker and saving the selected image from the image picker in core data? Similiar to the Bookworm app, I want the user to be able to select an image from an image picker and upload it to the content view as a navigation link so the user can view the image with the name and description as well as being able to delete the image. Thank you very much.

2      

I assume that you want the image to display in the app not just to save it, as it would be better to save image in the PhotoLibray of user.

https://www.hackingwithswift.com/books/ios-swiftui/how-to-save-images-to-the-users-photo-library

Check this out

https://medium.com/better-programming/how-to-save-an-image-to-core-data-with-swift-a1105ae2cf04

the bit about saving/retrieving to CoreData

then you need to convert from UIImage to Image

guard let uiImage = UIImage(data: imageData as Data) else { return }
image = Image(uiImage: uiImage)

then you can show image.

I have not done it Coredata but have done similar in Cloudkit.

2      

I found a youtube video on how to save and image with core data and swiftui. It is an hour long and has no sound after the first 4 minutes. The reason it is so long is because the person can't type very fast and probably doesn't speak english very well. The video is worth it and now I am able to save images with Core Data and SwifUI. Here's the link. [https://www.youtube.com/watch?v=XxjbecMKP54]. Restart the video to see the project that is made.

2      

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!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.