6. Swift Data Many to Many relationships

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

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

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

    Another fantastic video Stewart, thanks a lot! The power Swift never ceases to amaze me :)

  • @dmacharo
    @dmacharo ปีที่แล้ว +7

    This is one of the BEST series on SwiftData out there and certainly the most comprehensive one! Thanks a million, Stewart!

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว +2

      Glad you think so! I am planning another one that is mostly MapKit, but it also uses SwiftData

  • @TomWGiles
    @TomWGiles ปีที่แล้ว +1

    Thanks again Stewart. A realistic example, that can be adopted/adapted for many applications. One view that could be added is a list of genres, each displaying the books that belong to it. That’s where you could also delete a genre, and see the full effect that that action would have, rather than scan the book list visually.

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว +1

      Yes, a lot more can be done with this app, but I needed to stop somewhere. I might do an extra video later on that adds on a few other things like editing genres as well.

  • @DavidKoontz
    @DavidKoontz 10 วันที่ผ่านมา

    I've been rewatching this series because I'm rusty on DB modeling in general. Boy of Boy does SwiftData remove tons of boiler plate code and work! What is NOT obvious to me is why in the 1-toMany the Quote.swift data model needed the "var book: Book?" property?
    Yet in the Many-to-Many Genere there is NOT a property back to the Book!

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

    Thanks!

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

      Thank you Andrew

  • @AndrewDChristie
    @AndrewDChristie ปีที่แล้ว

    Thanks!

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

    Hi, deleting a genre BooklistView for other books will not automatically update the view immediately, the deleted genre will still be displayed in the bookListView.

  • @dibjr
    @dibjr ปีที่แล้ว

    Stewart, great video as usual!

  • @Mahadev-x7u
    @Mahadev-x7u ปีที่แล้ว +1

    Infinite gratitude for all lessons Stewart 🙏💯 for top explanation and top self giving…💯♨️ special for colors 🙌 Beautiful and Nice Christmas 🎄 for you and your family ❤ Wish you Health and long life 💯🙏

  • @holycrosscv
    @holycrosscv ปีที่แล้ว

    This is one of my favorite series Stewart! It is so well done. I have many projects with Core Data, and SwiftData is so much more approachable. Thanks for a fantastic series!
    One question, will you be covering modifying and existing Core Data project to SwiftData? Thanks again!

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว

      Not in this series but I might add a video on the topic next year.

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

    Great tutorial, thank you.
    However, all tutorials, including this one, assume that there is still a 1:1 relationship between the types used. So "Genre" "Book".
    And how do I handle inheritance with SwiftData if I want the Genres to hold references to books, movies, and theatrical plays, for example? So "Genre" "Book, Movies, Play, ..." You need some base type that those types conform to.
    I would go with a protocol called "Genreable," put the optional array attribute of Genre references in there, and assign the protocol to books, movies, and plays. This way, in a non-SwiftData world, I could use the protocol type for the reference Array inside Genre. However, this does not work with SwiftData, as it tells me that "Type 'any Genreable' cannot conform to PersistentModel."
    Any advice would be appreciated! Thanks.

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

    Thank you for the videos
    I also have a question , the genre circle work when I run the simolatore but not in the preview , I also download your code and it still not working I can't see the circles in the booklist view :( any ides why its append ?

  • @allenwixted1992
    @allenwixted1992 ปีที่แล้ว +1

    These are great. And plans to cover CloudKit and previews together?

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว +1

      Cloudkit is coming before Christmas

    • @allenwixted1992
      @allenwixted1992 ปีที่แล้ว

      @@StewartLynch amazing! 🤩

    • @allenwixted1992
      @allenwixted1992 ปีที่แล้ว +1

      @@StewartLynch since adding CloudKit my previews crash. Looking forward to seeing how it’s done!

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว

      I have had no issues with my implementation as you will see.

    • @allenwixted1992
      @allenwixted1992 ปีที่แล้ว

      @@StewartLynch fantastic. Am sure I missed something basic. Appreciate it a lot!

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

    Great video. In it you say that you want to specify the inverse relationship between \Genre.books and \Book.genres, but you don't really say why you want to do that?

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

      I don’t recall if I ever used this now, but you can specify the inverse to that the relationship can be inferred both ways giving you the ability to perform methods affecting models in both directions

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

    How did you highlight the if/else block and just enclose it in a group? I always cut the highlighted block, create the group, then past it inside.

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

      Just highlight the code and type { or and of the enclosure brackets like ( or [

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

      @@StewartLynch can't believe I never knew that! Thanks!

  • @peterbien2879
    @peterbien2879 ปีที่แล้ว

    Stewart, I am very enthusiastic about following your tutorials on TH-cam. I have a running project (just for fun) in which I have provided the auxiliary table Z_1GENRES with additional fields so that I can provide each many to many connection with additional properties. In my existing project with Vapor, I could also do this by simply defining a class that reflects this auxiliary table. Do you have a tip on how to do this with SwiftData?

  • @larschristiansen3136
    @larschristiansen3136 ปีที่แล้ว

    Thanks Stewart for this video. I do not seem to be able to find the link to the extensions mentioned in the video. Do I need to change my glasses ?

    • @StewartLynch
      @StewartLynch  ปีที่แล้ว

      Thanks Lars. I have added it to the description now

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

    Thank you for the video dear friend.
    Alas, SwiftData is still not ready for real life, for example you can never filter your books by tag, you will get an error if you try to do that. That's just the way Apple is...

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

      You can filter in memory and not use a query

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

    Like the pace of the video, where he pauses like he's coding/thinking along side us. Compared to someone just copy code from another screen.

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

      Thanks. That is what I am doing.

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

    love your content, but the audio quality needs some attention. getting crackles and distortion.

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

      I think you will find that in my more recent videos the audio is better. Just remember the content is free.

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

      @@StewartLynch Oh yes, really appreciate the high-quality content itself. Thanks much.

  • @AndrewDChristie
    @AndrewDChristie ปีที่แล้ว

    Thanks!

  • @AndrewDChristie
    @AndrewDChristie ปีที่แล้ว

    Thanks!