1. Camera Photos SwiftData: DataModel and View Setup

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

ความคิดเห็น • 55

  • @sybermaxable
    @sybermaxable 22 วันที่ผ่านมา

    Thank you Stewart, your channel is my #1 source of learning SwiftUI.

  • @iosjess
    @iosjess 2 หลายเดือนก่อน

    This is so helpful. Working with SwiftData and previews has been so difficult without your help.

    • @StewartLynch
      @StewartLynch  2 หลายเดือนก่อน

      Glad it is helping! It got even easier this year. Check out this video. th-cam.com/video/leTxwLXghVs/w-d-xo.html

  • @predicked
    @predicked 4 หลายเดือนก่อน +2

    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.

    • @StewartLynch
      @StewartLynch  4 หลายเดือนก่อน

      Glad you found it helpful

  • @vladimirmoor
    @vladimirmoor 3 หลายเดือนก่อน

    Great job on the explanation! The video is packed with tons of small yet meaningful details that really make a difference. Much appreciated!🥰

    • @StewartLynch
      @StewartLynch  3 หลายเดือนก่อน

      Awesome, thank you!

  • @dmacharo
    @dmacharo 9 หลายเดือนก่อน +1

    What a treat! Can't wait for the rest of the series, thanks a million Stuart!

  • @DanielLeightonArt
    @DanielLeightonArt หลายเดือนก่อน

    Great content, Stewart! Thank you!

    • @StewartLynch
      @StewartLynch  หลายเดือนก่อน +1

      Glad you are enjoying the videos!

  • @Mahadev-x7u
    @Mahadev-x7u 8 หลายเดือนก่อน +1

    Thank you so much Stewart 💯

  • @mhfs61
    @mhfs61 6 หลายเดือนก่อน

    Thank you Stewart.

    • @StewartLynch
      @StewartLynch  6 หลายเดือนก่อน

      You are very welcome

  • @sergiovinhal5934
    @sergiovinhal5934 9 หลายเดือนก่อน +1

    Thank you .

  • @mkhasson97
    @mkhasson97 9 หลายเดือนก่อน

    Thank you very much for you awersome videos and the perfect explainations

    • @StewartLynch
      @StewartLynch  9 หลายเดือนก่อน

      Glad you like them!

  • @isaiasizquierdo3369
    @isaiasizquierdo3369 8 หลายเดือนก่อน

    Thank you

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      You're welcome

  • @dirkfu6280
    @dirkfu6280 8 หลายเดือนก่อน

    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?

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      You are correct. Simpler indeed

  • @BlerdGrid
    @BlerdGrid 8 หลายเดือนก่อน

    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!

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      I doubt that would be the problem. Without seeing your project it is difficult to to comment on what might be causing the issue.

    • @DanielLeightonArt
      @DanielLeightonArt หลายเดือนก่อน

      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

  • @yifanisme
    @yifanisme 7 หลายเดือนก่อน +1

    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
      @StewartLynch  7 หลายเดือนก่อน

      Does it give the same error if you check my completed source code for this branch?

    • @gcoldfyre
      @gcoldfyre 5 หลายเดือนก่อน

      @@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
      @StewartLynch  5 หลายเดือนก่อน

      I just downloaded and tested the completed code for this project and get no errors.

    • @gcoldfyre
      @gcoldfyre 5 หลายเดือนก่อน

      @@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.

  • @marcskieskie6493
    @marcskieskie6493 5 หลายเดือนก่อน

    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) ?

    • @StewartLynch
      @StewartLynch  4 หลายเดือนก่อน +1

      You will have to design your own camera. This one that you get is pretty basic unfortunately.

    • @marcskieskie6493
      @marcskieskie6493 4 หลายเดือนก่อน

      @@StewartLynch Thanks for your reply.
      I'll give it a try.

  • @joywu1
    @joywu1 8 หลายเดือนก่อน

    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?

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      That would be another level and some reverse geocode lookup on the meta data.

    • @joywu1
      @joywu1 8 หลายเดือนก่อน

      @@StewartLynch thank you for your explanation, would you have any plans to this function in the future serious?

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน +1

      @@joywu1 I have a lot of other videos planned right now but I will add this to my list

  • @Johnson4o
    @Johnson4o 6 หลายเดือนก่อน

    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!

    • @StewartLynch
      @StewartLynch  6 หลายเดือนก่อน

      Try changing the constant to this:
      enum Constants {
      static let placeholder = UIImage(systemName: "photo.fill")!.withRenderingMode(.alwaysTemplate)
      }

  • @RaethanChristianSupatan
    @RaethanChristianSupatan 8 หลายเดือนก่อน

    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?

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      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.

    • @RaethanChristianSupatan
      @RaethanChristianSupatan 8 หลายเดือนก่อน

      @@StewartLynch Is that the reason why performance was slow? Also, can I not store my array of data property to external storage?

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      I have been reading that this is problematic. I have had no issues using one to many releationship.

    • @RaethanChristianSupatan
      @RaethanChristianSupatan 8 หลายเดือนก่อน

      @@StewartLynch I see tysm!

    • @raethansupatan7341
      @raethansupatan7341 8 หลายเดือนก่อน

      Is there a way to load the image data asynchronously?

  • @RoxieS-pv4ke
    @RoxieS-pv4ke 9 หลายเดือนก่อน +1

    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 TH-cam

    • @StewartLynch
      @StewartLynch  9 หลายเดือนก่อน

      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.

    • @RoxieS-pv4ke
      @RoxieS-pv4ke 8 หลายเดือนก่อน

      @@StewartLynch yes, but I think the second property needs to be included in the new photo model is ID

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      Id is not necessary a Swift data model already has a record Id.

    • @RoxieS-pv4ke
      @RoxieS-pv4ke 8 หลายเดือนก่อน

      @@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

    • @StewartLynch
      @StewartLynch  8 หลายเดือนก่อน

      @RoxieS-pv4ke What do you mean, throws it out of the application? What is your delete rule on the relationship?