How To Store An Image In SwiftData 📸 | SwiftData Tutorial | #8

Поделиться
HTML-код
  • Опубликовано: 13 окт 2024

Комментарии • 79

  • @tundsdev
    @tundsdev  Год назад +2

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

    • @tundsdev
      @tundsdev  10 месяцев назад +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.

    • @holycrosscv
      @holycrosscv 8 месяцев назад

      I removed the lib, and it still selects just the last image. @@tundsdev

  • @gccount
    @gccount 6 месяцев назад +2

    finally , this video helped me. the key part is converting image data to UIImage , then to Image

    • @tundsdev
      @tundsdev  6 месяцев назад

      Glad it helped!

  • @penyt
    @penyt Год назад +3

    Looking forward to CloudKit with SwiftData! Thanks for another super useful tutorial :)

    • @tundsdev
      @tundsdev  Год назад

      Glad you enjoyed it 👌🏾

  • @CarlosRomanAlcaide
    @CarlosRomanAlcaide 4 месяца назад +1

    This video is one of the best explanations I’ve found about how to store images in SwiftUI!

    • @tundsdev
      @tundsdev  4 месяца назад

      Glad it was helpful!

  • @nileshjdarji
    @nileshjdarji 2 месяца назад

    Wow Tunds. I like what you showed for the external storage. Very nice. I am really enjoying this series.

  • @jessicathedoc8569
    @jessicathedoc8569 2 дня назад

    Great content!!!

  • @kkpvb
    @kkpvb Год назад +2

    Good Tutorial, I’m learning SwiftUI from Thailand. 🙌🏻

    • @tundsdev
      @tundsdev  Год назад +2

      Awesome i recently went bangkok it was really nice, especially your mcdonalds 💕

    • @kkpvb
      @kkpvb Год назад +1

      Really?, I guess if you've been here recently Show that you like McDonald's decorated as Newjeans for sure hahaha

  • @HaukeCode-ye8fe
    @HaukeCode-ye8fe Год назад +2

    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!

    • @tundsdev
      @tundsdev  Год назад

      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?

    • @HaukeCode-ye8fe
      @HaukeCode-ye8fe Год назад

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

  • @ConnorH713
    @ConnorH713 Год назад

    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!

  • @thomasfahlke4253
    @thomasfahlke4253 Год назад +1

    Hi tunds, great work and yes, I learned a lot. Just right for the next project. Thank you

    • @tundsdev
      @tundsdev  Год назад

      That’s great to hear 👌🏾

  • @sxmiotb2834
    @sxmiotb2834 Год назад +1

    this was a big help. thank you so much

    • @tundsdev
      @tundsdev  Год назад

      Great to hear 👌🏾

  • @pgong415
    @pgong415 10 месяцев назад

    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.

    • @tundsdev
      @tundsdev  10 месяцев назад

      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 👌🏾

    • @tundsdev
      @tundsdev  10 месяцев назад

      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.

  • @profgallaugher
    @profgallaugher 8 месяцев назад +1

    Your work is great. Keep at it!

    • @tundsdev
      @tundsdev  8 месяцев назад

      Thanks a lot!

  • @macmcmillen6282
    @macmcmillen6282 Год назад

    Excellent series of videos. You explain things very well, so thanks for sharing this!

    • @tundsdev
      @tundsdev  Год назад +1

      Thanks, glad you enjoyed it 🤝

  • @ben.aka.bigben
    @ben.aka.bigben 10 месяцев назад

    Well done, thank you for this valuable tutorial

  • @keatsp
    @keatsp 11 месяцев назад

    Amazing job. Very easy to follow your tutorials. I would love to see how to get an image from the camera.

    • @tundsdev
      @tundsdev  11 месяцев назад

      Thanks & SwiftUI doesn’t support choosing the camera as an option just yet you still have to use UIKit mixed in with SwiftUI 👌🏾

  • @misaellanderosichante3293
    @misaellanderosichante3293 4 месяца назад

    Good tutorial bro help me a lot

  • @nguyenan8327
    @nguyenan8327 10 месяцев назад

    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?

    • @tundsdev
      @tundsdev  10 месяцев назад

      👋🏾 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

    • @nguyenan8327
      @nguyenan8327 10 месяцев назад

      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 😅

  • @lickmyshoe182
    @lickmyshoe182 Год назад +1

    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!

    • @tundsdev
      @tundsdev  Год назад

      This is great to hear, glad you enjoy the content 🙏🏾

  • @ian7666
    @ian7666 Год назад +1

    Be nice to see a comparison of SwiftData and Realm… I love Realm, should I even think of using SwiftData?

    • @tundsdev
      @tundsdev  Год назад

      Nice suggestion, i'll consider it!

  • @rudiprestianni7822
    @rudiprestianni7822 Год назад

    really like your tutorials. Would you do a tutorial on how to handle dictionaries with SwiftData?

    • @tundsdev
      @tundsdev  Год назад

      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

  • @meet071
    @meet071 Год назад +4

    Hello. Can you please share how we can store multiple images as a form of array in swiftData. Thanks :)

  • @w0mblemania
    @w0mblemania Год назад

    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?

    • @tundsdev
      @tundsdev  Год назад

      Thanks & nope to get that functionality you’d to setup an icloud container, which I may have a video on very very soon 👀

    • @w0mblemania
      @w0mblemania Год назад

      @@tundsdev Thanks!

  • @PeteLorimer
    @PeteLorimer Год назад

    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?

    • @tundsdev
      @tundsdev  Год назад +1

      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 👌🏾

  • @WilfClegg
    @WilfClegg 11 месяцев назад

    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

    • @tundsdev
      @tundsdev  10 месяцев назад

      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.

    • @WilfClegg
      @WilfClegg 10 месяцев назад

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

    • @tundsdev
      @tundsdev  10 месяцев назад

      @WilfClegg Yep that should work too 👌🏾

  • @macmcmillen6282
    @macmcmillen6282 Год назад +1

    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.

  • @misaellanderosichante3293
    @misaellanderosichante3293 4 месяца назад

    Would the image sync with CloudKit if we use external storage?

  • @kenturnbull9679
    @kenturnbull9679 Год назад

    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
      @tundsdev  Год назад

      I love jam butties 🔥🔥🔥
      i did consider it but the video would be way too long 😬

    • @kenturnbull9679
      @kenturnbull9679 Год назад

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

    • @TB84060
      @TB84060 11 месяцев назад

      Yes, please help with this. I am in the exact same quandary. I want to show a horizontal scrollview of images for each item.

  • @이도헌-m3k
    @이도헌-m3k Год назад

    I'd like to learn how to handle images in Coredata, is there a video on that?

    • @tundsdev
      @tundsdev  Год назад

      Nope, not yet. Maybe i’ll add it to my shortlist 👌🏾

    • @이도헌-m3k
      @이도헌-m3k Год назад

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

  • @anirudhcodes
    @anirudhcodes Год назад +1

    Awesome

    • @tundsdev
      @tundsdev  Год назад

      Glad you enjoyed it 👌🏾

  • @huynhvandutran8014
    @huynhvandutran8014 10 месяцев назад

    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.

    • @tundsdev
      @tundsdev  10 месяцев назад

      👋🏾 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

  • @benjiloya_ios_dev
    @benjiloya_ios_dev 10 месяцев назад

    how to add Video in swiftData???

  • @johnpill1
    @johnpill1 7 месяцев назад

    Came here for the tutorial... left to get a bacon butty 😂

    • @tundsdev
      @tundsdev  7 месяцев назад

      Brown, Ketchup or Both sauces? Which one are you? 👀

    • @johnpill1
      @johnpill1 7 месяцев назад +1

      @@tundsdev Bacon bap = BBQ. Sausage bap = Ketchup. Fry up = Brown. There are rules :D

    • @johnpill1
      @johnpill1 7 месяцев назад

      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?

    • @tundsdev
      @tundsdev  7 месяцев назад

      I’d need more context to try to help out unfortunately, this sounds very specific to your project

  • @holycrosscv
    @holycrosscv Год назад

    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

    • @holycrosscv
      @holycrosscv Год назад

      Ah, beta 6 added deleteRule: .nullify

    • @tundsdev
      @tundsdev  Год назад

      Haha yep, no worries glad you enjoyed the vid 👌🏾