Great content, Stewart! This tutorial on setting up the DataModel and View for Camera Photos in SwiftData is incredibly clear and well-structured. The step-by-step guidance made it easy to follow along, and I appreciate how you broke down the complex concepts into manageable parts. Thanks for providing such valuable content. Looking forward to other app tutorials.
Hi Stewart, great video again, can't wait to find out what solution you came up with in the camera part, especially because there is no SwiftUI API (yet?). Small nitpick: Instead of Image (uiImage: sample.image == nil? Constants.placeholder : sample.image!) whouldn't be Image (uiImage: sample.image ?? Constants.placeholder) much simpler?
Hey Stewart, thanks for this video series! It's helping me get through a project I'm working on. I'm hitting an error that I can't figure out though. When I add the "List(samples)" closure I get a "Failed to produce diagnostic for expression" error. I removed that block of code and the error went away...so my question is, would I need to add a "if let" to unwrap the image(s)? Thanks again!
I had this same problem and fixed it by force unwrapping placeholder in Constants.swift: static let placeholder = UIImage(systemName: "photo.fill")! Stewart has it in the video but I missed it
Hi, for the image I need to do like this else it will popup the error Image(uiImage: (sample.image == nil ? Constants.placeholder : sample.image)!) do you know why?
@@StewartLynch it does for me. When I add that line I get a "Failed to produce diagnostic for expression, please submit a bug report." I tried with both the completed code from source branch 2 and 3 as well but this line remains the same and gives me a Failed to build PhotosListView.swift error on the app
@@StewartLynch Yep, I ran it from your project and it worked fine. I don't see any differences between your code and mine but thanks for the reply. Loving your series so far! I'll continue through this example now.
The placeholder images are not visible in dark mode, is there any way to fix this? The image generated by systemImage is gray, so it’s perfectly visible in dark mode, however the image generated by systemName is black with transparent elements, so it becomes completely invisible in dark mode. Otherwise awesome tutorial, thank you!
Hi! I tried storing multiple photos as an array of data but when I try to display them in a lazyvgrid, the performance of the app become slow. Is there any way to improve performance if there are a lot of photos to be displayed?
Do you mean you have a property that is an array of Data? If so, create a new object with a Data property and then store as a one to many relationsip to that object.
make a video how to add an array of images or videos to a SwiftData, and I'm wondering right now if I store images not in a Data? but in an URL? ,,, it will be very interesting, there are no such lessons on UA-cam
This is pretty straight forward. Whether you are saving as a URL or as Data, create a new model for the image. It might only have the single property for the data or url. Then you can link the array to your object as a one to many relationship.
@@StewartLynch today I will try to change the code a little)) and then I did it in my model using an attribute, it works - adds an array of photos, but when deleting an entry, it throws it out of the application
Great content, Stewart! This tutorial on setting up the DataModel and View for Camera Photos in SwiftData is incredibly clear and well-structured. The step-by-step guidance made it easy to follow along, and I appreciate how you broke down the complex concepts into manageable parts. Thanks for providing such valuable content. Looking forward to other app tutorials.
Glad you found it helpful
This is so helpful. Working with SwiftData and previews has been so difficult without your help.
Glad it is helping! It got even easier this year. Check out this video. ua-cam.com/video/leTxwLXghVs/v-deo.html
Great job on the explanation! The video is packed with tons of small yet meaningful details that really make a difference. Much appreciated!🥰
Awesome, thank you!
What a treat! Can't wait for the rest of the series, thanks a million Stuart!
Thank you so much Stewart 💯
Great content, Stewart! Thank you!
Glad you are enjoying the videos!
Thank you very much for you awersome videos and the perfect explainations
Glad you like them!
Thank you Stewart.
You are very welcome
Thank you .
Thank you
You're welcome
Hi Stewart,
great video again, can't wait to find out what solution you came up with in the camera part, especially because there is no SwiftUI API (yet?).
Small nitpick:
Instead of
Image (uiImage: sample.image == nil? Constants.placeholder : sample.image!)
whouldn't be
Image (uiImage: sample.image ?? Constants.placeholder)
much simpler?
You are correct. Simpler indeed
I had seen your old series in this function(not swift data), but can you add one more function is when I pick the photo will show the photo on map?
That would be another level and some reverse geocode lookup on the meta data.
@@StewartLynch thank you for your explanation, would you have any plans to this function in the future serious?
@@joywu1 I have a lot of other videos planned right now but I will add this to my list
Hey Stewart, thanks for this video series! It's helping me get through a project I'm working on. I'm hitting an error that I can't figure out though. When I add the "List(samples)" closure I get a "Failed to produce diagnostic for expression" error. I removed that block of code and the error went away...so my question is, would I need to add a "if let" to unwrap the image(s)? Thanks again!
I doubt that would be the problem. Without seeing your project it is difficult to to comment on what might be causing the issue.
I had this same problem and fixed it by force unwrapping placeholder in Constants.swift: static let placeholder = UIImage(systemName: "photo.fill")!
Stewart has it in the video but I missed it
Hi, for the image I need to do like this else it will popup the error Image(uiImage: (sample.image == nil ? Constants.placeholder : sample.image)!)
do you know why?
Does it give the same error if you check my completed source code for this branch?
@@StewartLynch it does for me. When I add that line I get a "Failed to produce diagnostic for expression, please submit a bug report." I tried with both the completed code from source branch 2 and 3 as well but this line remains the same and gives me a Failed to build PhotosListView.swift error on the app
I just downloaded and tested the completed code for this project and get no errors.
@@StewartLynch Yep, I ran it from your project and it worked fine. I don't see any differences between your code and mine but thanks for the reply. Loving your series so far! I'll continue through this example now.
Hello, How make for take photo in square (1:1) mode ? or allow the user to switch the mode (4:3, 1:1; 16:9) ?
You will have to design your own camera. This one that you get is pretty basic unfortunately.
@@StewartLynch Thanks for your reply.
I'll give it a try.
The placeholder images are not visible in dark mode, is there any way to fix this? The image generated by systemImage is gray, so it’s perfectly visible in dark mode, however the image generated by systemName is black with transparent elements, so it becomes completely invisible in dark mode. Otherwise awesome tutorial, thank you!
Try changing the constant to this:
enum Constants {
static let placeholder = UIImage(systemName: "photo.fill")!.withRenderingMode(.alwaysTemplate)
}
Hi! I tried storing multiple photos as an array of data but when I try to display them in a lazyvgrid, the performance of the app become slow. Is there any way to improve performance if there are a lot of photos to be displayed?
Do you mean you have a property that is an array of Data? If so, create a new object with a Data property and then store as a one to many relationsip to that object.
@@StewartLynch Is that the reason why performance was slow? Also, can I not store my array of data property to external storage?
I have been reading that this is problematic. I have had no issues using one to many releationship.
@@StewartLynch I see tysm!
Is there a way to load the image data asynchronously?
make a video how to add an array of images or videos to a SwiftData, and I'm wondering right now if I store images not in a Data? but in an URL? ,,, it will be very interesting, there are no such lessons on UA-cam
This is pretty straight forward. Whether you are saving as a URL or as Data, create a new model for the image. It might only have the single property for the data or url. Then you can link the array to your object as a one to many relationship.
@@StewartLynch yes, but I think the second property needs to be included in the new photo model is ID
Id is not necessary a Swift data model already has a record Id.
@@StewartLynch today I will try to change the code a little)) and then I did it in my model using an attribute, it works - adds an array of photos, but when deleting an entry, it throws it out of the application
@RoxieS-pv4ke What do you mean, throws it out of the application? What is your delete rule on the relationship?