Working with relationships - SwiftData Starter Project 7/8

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

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

  • @TarotPolitics
    @TarotPolitics 9 месяцев назад

    Excellent, Paul! I purchased your book about SwiftData, super helpful! As it happens I am only seeing the video now a month later which is cool. Thank you for all you do!

    • @gabrielrml
      @gabrielrml 27 дней назад

      Where did you get it?

  • @elemento_arts
    @elemento_arts 5 месяцев назад

    Omg.. this is magic. Migration after a adding a single new property in Core Data was an absolute horror nightmare. God bless SwiftData

  • @msch3988
    @msch3988 3 месяца назад

    Thank You so much! Best tutorial for SwiftData with sorts&searches! 🎉

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

    Good day! Amazing tutorial, could you tell how we can sort Sights? It may be useful for someone, who creating chat and put messages inside chat model, like you put Sight into Destination 🙂

  • @AmmarSMitoori
    @AmmarSMitoori Месяц назад

    Some question came to my mind. what if I want to go from sight to its parent destination record, how can that be done ?

  • @calpilotmike
    @calpilotmike 10 месяцев назад +1

    How about if Sights had several other fields, and I wanted to move to a subview to further edit a Sight? How would we access the model context in order to persist changes to those particular objects? A new subview for editing Sights does not appear to like me bringing in the context with @Environment (only the top-level app object only has access to the modelContainer?). Would we pass just the Sight to the subview, or the whole Destination?

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

    Thanks for your great video! So if you could continue add sights, which are in normal order by adding ? Because mine's not 😭

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

    When I add
    var sights = [Sight]() I receive an error Variable’self’._$backData’ used before initialization?

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

    The EditDestinationView preview always crashes when appending to the sights array - tried a bunch of different things but I'm quite lost, is there anything that can be done in order for it to work?

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

      I can work around the preview issue by using a codable struct instead of the sight @Model but this is super strange...
      // This works
      struct Sight: Codable {
      var name: String
      }
      // This explodes
      @Model
      class Sight {
      var name: String
      init(name: String) {
      self.name = name
      }
      }

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

    In previous betas, we had to perform migrations by writing code. As you point out, the migration in this episode is performed without any action or code being written by us; what was previously referred to as a 'simple' migration. Is this now a general feature of SwiftData or are there more complex migrations that will still require coding on our part?

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

      If you erase the contents and settings on the simulator device, then rebuild, the new simulator database will have the new code. It's only when doing complex migrations that you'll need to follow a schema migration plan. See Paul's article: "How to create a complex migration using VersionedSchema".

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

    How does one delete a site that has been added? I tried wrapping the sites ForEach with a List, adding an .onDelete modifier that called a deleteSite method similar to the one in DestinationListingView. I added a modelContext environment variable to EditDestinationView but was getting xCode errors showing a type mismatch.

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

      I tried that too, and Xcode opened up the macro code on class Sight, and at the line
      return self.getValue(forKey: \.name)
      there was an exception: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a8a4fad8)
      Not helpful at all.
      But I reran the app, and the Sight I had edited was gone.

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

    what happened to the rule that the init need to set every variable, particularly after you add the sights array?

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

      The sights array is initialized where it's declared as an empty array

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

      the init doesn't need to set the variables that have a default value, and the sights array has the default value [Sight]() which is an empty array of sights