2. SwiftData Containers and Preview Data

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

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

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

    Hi Stewart, I just wanted to say thank you! With you expertise and you nice way to explain things you're helping me very much! Keep up the exceptional work, you are one of a kind here on youtube!

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

      Thank you

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

    Great explanation of the notion of containers, schemas and configs.
    Quite comparable to CoreDate at this point.
    As usually Stewarts development is a great learning experience.
    On to the next one.

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

    Great tutorial, the Preview Containers, and Mock Data are very helpful when working with SwiftData.

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

    Great way of providing an in memory container and sample data! Love it!

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

    Thank you for showing the retrieval from git hub in the beginning

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

    This is exactly what I need. Thank you Stewart!

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

    Amazing content…💯 thank you Stewart

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

    Many thanks, great tutorial

  • @joser.oleriano2148
    @joser.oleriano2148 ปีที่แล้ว

    Great explanation! Thanks for video...

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

    Most excellent Stewart. Thanks for this great continuing training.
    One question, though: does the rating in the preview match the rating on the simulator? In my code, I notice the preview rating is one less star. Thanks.

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

      I cover this in a later video. This is not a particularly good example. In my next series on Source control, I recreate it better

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

      @@StewartLynch thanks Stewart. I look forward to future installments.

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

    ah - I followed but was not quite sure where we were going with that video... think I will have to come back to this one later.

  • @michaelhalley-frame3328
    @michaelhalley-frame3328 3 หลายเดือนก่อน

    Great tutorial, thank you!
    One error I get is that I’m using I/O on main thread. Any guides on refactoring to avoid this?

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

      Do you get this error when you are executing the code from my repository? If so, can you tell me exactly when this happens in the video?

    • @michaelhalley-frame3328
      @michaelhalley-frame3328 3 หลายเดือนก่อน

      @@StewartLynch I’ve gone back to it tonight and it’s completely resolved. It was an error next to the struct AppName: App { line.
      Probably ok, just got me wondering if this pattern needed to consider performance for a real world app.
      Thank you for taking the time to reply!

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

    Hey Stewart, has the behavior regarding persistance of enums in SwifData changed recently? In the application I'm working on I have an enum that has String as rawvalues, and String is precisely the type I see on my database table without having to have set .Rawvalue in the stored property inside the model class

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

      That sounds great. I have not checked recently

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

    Thanks. Great Job!

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

    hi, my preview has crashed when i insert the mock data to the app, have any tips ? thanks

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

      Compare your code to the my completed branch on my Git repository. You might also do a Command SHift K on Xcode. That sometimes clears up issues in Preview too.

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

    Great video. Works as a charm except when I try to archive the product, the compiler throws the error “No exact matches in call to initializer”. After I clicked on error the XCode navigates me to the #Preview section. The error disappeared and grey message “Candidate has partially matching parameter list…” appears instead. This behaviour prevents the deployment. Any suggestion will be highly appreciated.

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

      I fix this issue in the final video

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

    How does one view the documentation like you showed at 3:51 ?

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

      Help Menu -> Developer Documentation in Xcode. You can search in there to find what you want.

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

    Amazing Stewart ! I'm in getting skills in iOS dev and it help me a lot !
    Maybe a stupid question, but I want to save settings of app in iCloud, therefore I expected to save the in swift data. So I will have to create a new Model. therefore, how to handle different models in a preview. Maybe there is something I don't understand.
    Thanks again !

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

      I don’t understand the question. Your modelContainer will contain all models that you have.

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

      @@StewartLynch
      Thanks Stewart.
      I added my new model in the schema of the init method to add it to the container:
      let schema = Schema([Entry.self, AppSettings.self])
      It works well.
      It's just about Preview.
      #Preview {
      let preview = Preview(Entry.self, AppSettings.self)
      preview.addExamples([Entry.sampleEntries), AppSettings.sampleAppSettings])
      return Home()
      .modelContainer(preview.container)
      }
      I get error at #Preview level : "Type of expression is ambiguous without a type annotation"

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

    Thanks!

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

    The preview thing is a handy trick, but it doesn't work when you have nested models. Like a parent model that has an array of child models. Because it seems like all children need to be insert()'d or save()'d first otherwise SwiftData crashes.

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

      Keep watching the series. I believe I cover this when I do relationships. Also. Get this book. www.bigmountainstudio.com/swiftdata/77jt8

  • @cuentayt-nh9qn
    @cuentayt-nh9qn 6 หลายเดือนก่อน

    ty crack