iOS 15: Dynamically filtering @FetchRequest with SwiftUI - Core Data SwiftUI Tutorial 6/7

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

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

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

    Great explanatiom - structured and detailed
    You rock!

  • @kslazinski
    @kslazinski 2 года назад +4

    Thank you for this and every other video, Paul. It’s very cool how you show practical examples of how things work. Easy to learn and implement in other apps. Thanks for the work you’re doing to help other people learn how to code

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

    5839 views and only 165 likes? Man, I am blown by this tutorial and I can never understand user behaviour. All I can say is a BIG THANK YOU.

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

      It may be that some viewers found this video to be overly, (unnecessarily?), complex.
      I, for one, will not be "liking" it because I'm still glazed over from all the "helpfulness".
      Maybe some of us would prefer a "for dummies" version. 🤓

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

    this completely went over my head the first time I attempted it. Rewatching it and resisting the urge to go straight for the shiny new SwiftData

  • @Pedro76mchlkg
    @Pedro76mchlkg 2 года назад +2

    I can’t thank you enough. You have the gift to make everything easier to understand. BTW, I would love to see a tutorial about core data in MVVM, or an explanation about why I should or should not separate core data from the view.
    Thank you so much for your tutorials!

    • @a.h.m1365
      @a.h.m1365 2 года назад

      as I Think Paul not a big fan of mvvm with swiftui

    • @DavidNitzscheBell
      @DavidNitzscheBell 2 года назад

      @@a.h.m1365 why do you think that? I've seen nothing to support that.

  • @lapusan2008
    @lapusan2008 2 года назад +1

    OMG! you’ve saved my ass. I’ve been trying endlessly for a solution until I’ve watched this video. Thank you!!

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

    Yikes! Such a long distance to have to go for something seemingly simple. (I'm Discouraged 😟)
    ...but I'm very impressed by **your** cleverness. 🤓
    Disclaimer: I'm a total newbie to Core Data in SwiftUI.
    Newb Question: Is there a reason you wouldn't create a fetch request inside the .xcdatamodeld file ?
    Thanks

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

    I used this approach to change the predicate in the init() for a fetch of Annotations on a Map in MapKit. Works fine but if I change a property on any of the fetched results objects then it removes the Object from the fetched results resulting in that Annotation disappearing from the map !

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

    I am so glad I stuck around. The second half of this lesson is worth my weight in Mithril (Sorry you said Lord of the Rings) . This is the best explanation of generics I have seen and by attaching to the CoreData fetch it over the top.
    Curious why you don't use #keyPath(Singer.lastName)
    Also I tend to level the leave Codegen as Class Definition and simply use extension in a separate file like this list for computed properties
    extension Singer {
    public var unwrappedLastName: String {
    lastName ?? "unknown"
    }
    }
    In doing so I feel it is easy in that I never have to regenerate the Entity manually

  • @nitesh-maharaj
    @nitesh-maharaj 2 года назад

    I do like the generic solution, although one change I'd make to add a bit more flexibility to this is pass in an NSPredicate to the initializer. So if for example the caller wants to filter on first or last name, then they could just change their predicate and aren't bound to the functionality of the black-boxed view.
    Thanks Paul.

    • @DavidNitzscheBell
      @DavidNitzscheBell 2 года назад

      I agree with you, sort of. This video shows precisely what you describe, being able to filter on first or last name. But, it doesn't allow for filters that are not "BEGINWITH". So, yes, it would be nice to have the predicate be a parameter. We should try it out.
      Also, I need to figure out how to allow the filter to also sort, dynamically.

    • @nitesh-maharaj
      @nitesh-maharaj 2 года назад

      @@DavidNitzscheBell To filter dynamically, the @FetchRequest should be in a sub view.

  • @DavidNitzscheBell
    @DavidNitzscheBell 2 года назад

    oooooh, this looks really good. I definitely need it.....

  • @Corban_Dallas
    @Corban_Dallas 2 года назад +3

    Very thanks!
    But I think making manual codegen for Singer class is a little excessive. We can just create extension for Singer class to add two value wrappers. It will be little simpler to do and look cleaner.

    • @DavidNitzscheBell
      @DavidNitzscheBell 2 года назад +1

      can you create an extension for Singer class if the Singer class is not created in code? Hmmmmmm. (testing...) Oh, wow! Yes, it seems you *can* create an extension. Clever!

  • @bbulliard
    @bbulliard 2 года назад

    Well done. Very, very nice! Thank you!

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

    Wow 🤩

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

    Great tutorial !!! help me a lot, may I ask how to count the total number of item after filtered ??

  • @GenZRadio234
    @GenZRadio234 2 года назад

    _ means your writing to the setter property. Also why not just set the .nspredicate property on your results if you want dynamic filtering🤔. Either way 🙌

  • @OttoSchmilinsky
    @OttoSchmilinsky 2 года назад +1

    Why does everyone write all the code inside the ContentView? Nobody makes subviews in other files, and I only found one that did the views but did not create the previews to see them on canvas. can you recommend me a book of complete MVVM examples? Thanks in advance.

    • @blinkpo4
      @blinkpo4 2 года назад +1

      Hi! Have you been able to find any useful books? I have the same problem. Applying MVVM with Core Data, FetchRequest and SwiftUI is a nightmare. Thanks in advance.

    • @mikehimself909
      @mikehimself909 2 года назад

      I found Paul’s video very helpful: ruclips.net/video/kfsA87qRC3Y/видео.html

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

    What is the data store changes though?

  • @javed2547
    @javed2547 2 года назад

    Is there any thread safety issues with passing the actual NSManagedObjects around?

  • @MoAdel92
    @MoAdel92 2 года назад

    I think swiftUI team is making this topic a little bit complicated
    I think the word a or s should be @state variable
    And then we can change it and the results show update on spot
    Excuse me i am a beginner with swiftUI
    But this what i thought 💭

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

    Muito bom o video, uma duvida como faria para processar o resultado e totalizar algum campo de valor...

  • @yhmlco
    @yhmlco 2 года назад +1

    Enjoying your videos but you're overcomplicating this one. Just reach into the fetchRequest from button or action handler and change the nsPredicate or nsSortDescriptors. View will automatically refetch.

  • @Moxific
    @Moxific 2 года назад

    What if we'd like to filter with two or more filter keys ?

  • @kiohaha
    @kiohaha 2 года назад

    omg its so hard to get the searchbar added to the list with this method. any ideas??

  • @mamazur
    @mamazur 2 года назад

    Hi Paul. Thanks for the amazing tutorial. I have one error

  • @Eronx
    @Eronx 2 года назад +1

    Hi,
    Is someone here to explain me why we used _fetchRequest and not just regular one?

    • @DavidNitzscheBell
      @DavidNitzscheBell 2 года назад

      Paul explained it in the video. It's very technical and tricky, but he explained it...

  • @hoagy_ytfc
    @hoagy_ytfc 2 года назад +5

    Great tutorial, but sadly dog-free this time! :)