1. Camera Photos SwiftData: DataModel and View Setup

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 54

  • @predicked
    @predicked 3 місяці тому +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.

  • @iosjess
    @iosjess 19 днів тому

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

    • @StewartLynch
      @StewartLynch  19 днів тому

      Glad it is helping! It got even easier this year. Check out this video. ua-cam.com/video/leTxwLXghVs/v-deo.html

  • @vladimirmoor
    @vladimirmoor 2 місяці тому

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

  • @dmacharo
    @dmacharo 7 місяців тому +1

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

  • @Mahadev-x7u
    @Mahadev-x7u 7 місяців тому +1

    Thank you so much Stewart 💯

  • @DanielLeightonArt
    @DanielLeightonArt 13 днів тому

    Great content, Stewart! Thank you!

    • @StewartLynch
      @StewartLynch  13 днів тому +1

      Glad you are enjoying the videos!

  • @mkhasson97
    @mkhasson97 7 місяців тому

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

  • @mhfs61
    @mhfs61 5 місяців тому

    Thank you Stewart.

  • @sergiovinhal5934
    @sergiovinhal5934 7 місяців тому +1

    Thank you .

  • @isaiasizquierdo3369
    @isaiasizquierdo3369 7 місяців тому

    Thank you

  • @dirkfu6280
    @dirkfu6280 7 місяців тому

    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  7 місяців тому

      You are correct. Simpler indeed

  • @joywu1
    @joywu1 7 місяців тому

    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  7 місяців тому

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

    • @joywu1
      @joywu1 7 місяців тому

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

    • @StewartLynch
      @StewartLynch  7 місяців тому +1

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

  • @BlerdGrid
    @BlerdGrid 6 місяців тому

    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  6 місяців тому

      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 15 днів тому

      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

  • @lfan_tv
    @lfan_tv 6 місяців тому +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  6 місяців тому

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

    • @gcoldfyre
      @gcoldfyre 3 місяці тому

      @@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  3 місяці тому

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

    • @gcoldfyre
      @gcoldfyre 3 місяці тому

      @@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 3 місяці тому

    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  3 місяці тому +1

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

    • @marcskieskie6493
      @marcskieskie6493 3 місяці тому

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

  • @Johnson4o
    @Johnson4o 4 місяці тому

    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  4 місяці тому

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

  • @RaethanChristianSupatan
    @RaethanChristianSupatan 7 місяців тому

    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  7 місяців тому

      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 7 місяців тому

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

    • @StewartLynch
      @StewartLynch  7 місяців тому

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

    • @RaethanChristianSupatan
      @RaethanChristianSupatan 7 місяців тому

      @@StewartLynch I see tysm!

    • @raethansupatan7341
      @raethansupatan7341 7 місяців тому

      Is there a way to load the image data asynchronously?

  • @RoxieS-pv4ke
    @RoxieS-pv4ke 7 місяців тому +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 UA-cam

    • @StewartLynch
      @StewartLynch  7 місяців тому

      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 7 місяців тому

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

    • @StewartLynch
      @StewartLynch  7 місяців тому

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

    • @RoxieS-pv4ke
      @RoxieS-pv4ke 7 місяців тому

      @@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  7 місяців тому

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