🚨Bug Fix🚨 There seems to be an issue with the way the clipping images is handled in SwiftUI it can cause elements to overflow and block the touch targets of other element in this case the todo button. In order to fix this you'll need to set the z index on the image to -1, below is an example of this Replace Image with the following below Image(uiImage: uiImage) .resizable() .aspectRatio(contentMode: .fill) .frame(height: 120) .clipShape( RoundedRectangle(cornerRadius: 10, style: .continuous) ) .zIndex(-1)
There seems to also be a bug where if you have multiple images on the screen you can only view the last one. Which seems to be a bug with the lib that I used oooppsss lol. I'll try to post a gist with a link to some update I made to resolve this issue.
Really loving these videos on SwiftData Tunds! Would love to see a lesson on how to integrate CloudKit with SwiftData so different users can access related data. Specifically would be cool to see an example where you use some shared cloud data as well as some local data and keep things straight. Thank you!
Thanks, glad you’re enjoying it. I do have some cloudkit content planned soon, for both this & another paid course i’m workin on. Also do you mean users can share todo’s? And like collaborate on them together?
@@tundsdev yes! A shared todo app where you can assign one another is a great example. Mostly wanting to learn how to think about managing local private data through SwiftData and then local shared data with SwiftData and iCloud and how to manage between them. For instance, what if I created a private todo and then later wanted to add someone else to it. Hope that makes sense, thanks! One other thing I am interested in, but may be to far off topic is also how you might manage local SwiftData and Firebase integration for cloud sharing.
First, your video is really helpful especially in terms of saving images in Data type rather than image one and storing the images in an external file. Second, there is a bug in my experiment - if pick one image for item 1, for example, and one image for item 2, item 3, so on, when you click on image for item 1 or item 2, always the image for item 3 (or last item) is presented. I do not know if this is the case for your app or something wrong for my experiment. Appreciate it in advance for your reply. Thank you for your efforts anyway.
Hi, So this does store the image externally it’s actually better to do this rather than store the data directly in the database, there’s been a few updates to Xcode since I last released this so i’d have to investigate this issue for you 👌🏾
Hey so I just had a quick look and it's linked to the library that I've used in the video...When I have some time i'll try to post a gist with an updated solution without the lib but it won't have zoom functionality etc.
Hi Tunds, thanks for your tutorial. However, i read in multiple places that we should not store image data directly in database field, should we do that for SwiftData as well, what's your ideas on this?
👋🏾 so technically this isnt stored in the database its stored in an external reference to a folder on the device to prevent large data being saved in the data model
oh thanks for your explanation if can pls help to guide on how to store multiple images in a record, thank you very much! I try the array but it keeps having some issues 😅
From one Brit to another - Thank you ever so much for these tutorials, the way you explain things is great and I genuinely understand the concepts once you’ve gone through them. Keep up the good work!
I have an upcoming vid that will show you how to handle custom data types SwiftData doesn’t support, another alternative is to use json & save it as a string amd convert it back to an object
This was very useful, thanks! Question: by default, if we use the .externalStorage attribute, are the images being saved in a place automatically backed up by iCloud?
Great video. I followed along and got images into my app in no time. Question: When using the @Attribute(.externalStorage) where exactly does the image get stored? And if I were to integrate CloudKit for syncing the data across all my devices, would the images get synced as well?
Thanks & similar to CoreData its stored in a hidden folder that is then referenced within SwiftData rather than the whole image being stored. I’ve not worked too much with CloudKit but it’s next up on my list to explore 👌🏾
Hi Tunds! Once again, many thanks for this tutorial. It rocks, as usual. I noticed a small bug (maybe it is on my install only?) When I add two or more items to the ToDo list (and each with a photo), The SwiftUIImageViewer doesn't always present the image that I tap on. Can you check on this to see if works ok on your install? Thanks....Wilf
Hey so I just had a quick look and it's linked to the library that I've used in the video...When I have some time i'll try to post a gist with an updated solution without the lib but it won't have zoom functionality etc.
@@tundsdev Thanks Tunds, I’m glad you confirmed the issue. Alternatively, I can create a .sheet, then apply .infinity framing, pinch and magnification, etc. This would avoid the need for an add-on package?
Have you tried saving multiple images per todo? I'm guessing that would require an array of the Data type. I see that Beta 8 has been released. Looks like a lot of SwiftData fixes.
I like this and can use it. I am working on an inspection app that requires more than one photo for an item. How about making your image into a carousel or horizontal scrollview to allow more than one image? As for Butties...do you still have Jam butties?
>@@tundsdev My friend from Manchester also used the expression ..."Manky" and called me Neddy; and I'm Canadian. How about another video on using the package to generate a collection of photos for an item? Love to see it extended.
@@tundsdev Thank you. I'm trying to store the image as a binary data type with Core Data, but most of them recommended storing only the PATH and managing it locally. If I store only PATH in coredata as recommended, won't the local images be deleted if the user deletes the app when using cloudkit? Then when I reinstall the app, I won't be able to retrieve the images even if PATH exists in coredata. I'm still looking for a way to store and manage them correctly in coredata (considering that there will be many images). I'd be grateful if you could post a video about it in the future. 🙏
Do you know where the actual data (imageData in your example) is stored when we use externalStorage? Like is it in the Document folder? I don't see the image data in there.
On a less serious note, I was trying to get a slider working in SwiftData in the Bindable view and I keep getting an error on the container form. Works fine in the original sheet. Is this a SwiftData issue or something I am missing?
Loving this series. Thanks! Did you find that @Relationship(.nullify, inverse: \Category.taskCat) throws an error with beta 6 "Type 'PropertyOptions' has no member 'nullify'" Thanks. Blessings, --Mark
🚨Bug Fix🚨
There seems to be an issue with the way the clipping images is handled in SwiftUI it can cause elements to overflow and block the touch targets of other element in this case the todo button. In order to fix this you'll need to set the z index on the image to -1, below is an example of this
Replace Image with the following below
Image(uiImage: uiImage)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(height: 120)
.clipShape(
RoundedRectangle(cornerRadius: 10,
style: .continuous)
)
.zIndex(-1)
There seems to also be a bug where if you have multiple images on the screen you can only view the last one. Which seems to be a bug with the lib that I used oooppsss lol. I'll try to post a gist with a link to some update I made to resolve this issue.
I removed the lib, and it still selects just the last image. @@tundsdev
finally , this video helped me. the key part is converting image data to UIImage , then to Image
Glad it helped!
Looking forward to CloudKit with SwiftData! Thanks for another super useful tutorial :)
Glad you enjoyed it 👌🏾
This video is one of the best explanations I’ve found about how to store images in SwiftUI!
Glad it was helpful!
Wow Tunds. I like what you showed for the external storage. Very nice. I am really enjoying this series.
Great content!!!
Good Tutorial, I’m learning SwiftUI from Thailand. 🙌🏻
Awesome i recently went bangkok it was really nice, especially your mcdonalds 💕
Really?, I guess if you've been here recently Show that you like McDonald's decorated as Newjeans for sure hahaha
Really loving these videos on SwiftData Tunds! Would love to see a lesson on how to integrate CloudKit with SwiftData so different users can access related data. Specifically would be cool to see an example where you use some shared cloud data as well as some local data and keep things straight. Thank you!
Thanks, glad you’re enjoying it. I do have some cloudkit content planned soon, for both this & another paid course i’m workin on.
Also do you mean users can share todo’s? And like collaborate on them together?
@@tundsdev yes! A shared todo app where you can assign one another is a great example. Mostly wanting to learn how to think about managing local private data through SwiftData and then local shared data with SwiftData and iCloud and how to manage between them. For instance, what if I created a private todo and then later wanted to add someone else to it. Hope that makes sense, thanks!
One other thing I am interested in, but may be to far off topic is also how you might manage local SwiftData and Firebase integration for cloud sharing.
Great video, before this I was trying to cherry pick from older Core Data tutorials to achieve this functionality for my app. Thanks for posting!
Glad it helped!
Hi tunds, great work and yes, I learned a lot. Just right for the next project. Thank you
That’s great to hear 👌🏾
this was a big help. thank you so much
Great to hear 👌🏾
First, your video is really helpful especially in terms of saving images in Data type rather than image one and storing the images in an external file. Second, there is a bug in my experiment - if pick one image for item 1, for example, and one image for item 2, item 3, so on, when you click on image for item 1 or item 2, always the image for item 3 (or last item) is presented. I do not know if this is the case for your app or something wrong for my experiment. Appreciate it in advance for your reply. Thank you for your efforts anyway.
Hi, So this does store the image externally it’s actually better to do this rather than store the data directly in the database, there’s been a few updates to Xcode since I last released this so i’d have to investigate this issue for you 👌🏾
Hey so I just had a quick look and it's linked to the library that I've used in the video...When I have some time i'll try to post a gist with an updated solution without the lib but it won't have zoom functionality etc.
Your work is great. Keep at it!
Thanks a lot!
Excellent series of videos. You explain things very well, so thanks for sharing this!
Thanks, glad you enjoyed it 🤝
Well done, thank you for this valuable tutorial
Amazing job. Very easy to follow your tutorials. I would love to see how to get an image from the camera.
Thanks & SwiftUI doesn’t support choosing the camera as an option just yet you still have to use UIKit mixed in with SwiftUI 👌🏾
Good tutorial bro help me a lot
Hi Tunds, thanks for your tutorial. However, i read in multiple places that we should not store image data directly in database field, should we do that for SwiftData as well, what's your ideas on this?
👋🏾 so technically this isnt stored in the database its stored in an external reference to a folder on the device to prevent large data being saved in the data model
oh thanks for your explanation
if can pls help to guide on how to store multiple images in a record, thank you very much! I try the array but it keeps having some issues 😅
From one Brit to another - Thank you ever so much for these tutorials, the way you explain things is great and I genuinely understand the concepts once you’ve gone through them. Keep up the good work!
This is great to hear, glad you enjoy the content 🙏🏾
Be nice to see a comparison of SwiftData and Realm… I love Realm, should I even think of using SwiftData?
Nice suggestion, i'll consider it!
really like your tutorials. Would you do a tutorial on how to handle dictionaries with SwiftData?
I have an upcoming vid that will show you how to handle custom data types SwiftData doesn’t support, another alternative is to use json & save it as a string amd convert it back to an object
Hello. Can you please share how we can store multiple images as a form of array in swiftData. Thanks :)
Sure I can add it to my list 👌🏾
Also interested in this.
This was very useful, thanks!
Question: by default, if we use the .externalStorage attribute, are the images being saved in a place automatically backed up by iCloud?
Thanks & nope to get that functionality you’d to setup an icloud container, which I may have a video on very very soon 👀
@@tundsdev Thanks!
Great video. I followed along and got images into my app in no time.
Question: When using the @Attribute(.externalStorage) where exactly does the image get stored? And if I were to integrate CloudKit for syncing the data across all my devices, would the images get synced as well?
Thanks & similar to CoreData its stored in a hidden folder that is then referenced within SwiftData rather than the whole image being stored. I’ve not worked too much with CloudKit but it’s next up on my list to explore 👌🏾
Hi Tunds! Once again, many thanks for this tutorial. It rocks, as usual. I noticed a small bug (maybe it is on my install only?) When I add two or more items to the ToDo list (and each with a photo), The SwiftUIImageViewer doesn't always present the image that I tap on. Can you check on this to see if works ok on your install? Thanks....Wilf
Hey so I just had a quick look and it's linked to the library that I've used in the video...When I have some time i'll try to post a gist with an updated solution without the lib but it won't have zoom functionality etc.
@@tundsdev Thanks Tunds, I’m glad you confirmed the issue. Alternatively, I can create a .sheet, then apply .infinity framing, pinch and magnification, etc. This would avoid the need for an add-on package?
@WilfClegg Yep that should work too 👌🏾
Have you tried saving multiple images per todo? I'm guessing that would require an array of the Data type. I see that Beta 8 has been released. Looks like a lot of SwiftData fixes.
Would the image sync with CloudKit if we use external storage?
I like this and can use it. I am working on an inspection app that requires more than one photo for an item. How about making your image into a carousel or horizontal scrollview to allow more than one image? As for Butties...do you still have Jam butties?
I love jam butties 🔥🔥🔥
i did consider it but the video would be way too long 😬
>@@tundsdev My friend from Manchester also used the expression ..."Manky" and called me Neddy; and I'm Canadian. How about another video on using the package to generate a collection of photos for an item? Love to see it extended.
Yes, please help with this. I am in the exact same quandary. I want to show a horizontal scrollview of images for each item.
I'd like to learn how to handle images in Coredata, is there a video on that?
Nope, not yet. Maybe i’ll add it to my shortlist 👌🏾
@@tundsdev Thank you. I'm trying to store the image as a binary data type with Core Data, but most of them recommended storing only the PATH and managing it locally. If I store only PATH in coredata as recommended, won't the local images be deleted if the user deletes the app when using cloudkit? Then when I reinstall the app, I won't be able to retrieve the images even if PATH exists in coredata. I'm still looking for a way to store and manage them correctly in coredata (considering that there will be many images). I'd be grateful if you could post a video about it in the future. 🙏
Awesome
Glad you enjoyed it 👌🏾
Do you know where the actual data (imageData in your example) is stored when we use externalStorage? Like is it in the Document folder? I don't see the image data in there.
👋🏾 You have to open up the path to the data model file and in that folder there is folder called external storage that holds all of the external files
how to add Video in swiftData???
Came here for the tutorial... left to get a bacon butty 😂
Brown, Ketchup or Both sauces? Which one are you? 👀
@@tundsdev Bacon bap = BBQ. Sausage bap = Ketchup. Fry up = Brown. There are rules :D
On a less serious note, I was trying to get a slider working in SwiftData in the Bindable view and I keep getting an error on the container form. Works fine in the original sheet. Is this a SwiftData issue or something I am missing?
I’d need more context to try to help out unfortunately, this sounds very specific to your project
Loving this series. Thanks!
Did you find that @Relationship(.nullify, inverse: \Category.taskCat) throws an error with beta 6 "Type 'PropertyOptions' has no member 'nullify'"
Thanks.
Blessings,
--Mark
Ah, beta 6 added deleteRule: .nullify
Haha yep, no worries glad you enjoyed the vid 👌🏾