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
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. 🤓
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!
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
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 !
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
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.
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.
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.
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!
_ 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 🙌
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.
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.
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 💭
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.
Great explanatiom - structured and detailed
You rock!
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
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.
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. 🤓
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
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!
as I Think Paul not a big fan of mvvm with swiftui
@@a.h.m1365 why do you think that? I've seen nothing to support that.
OMG! you’ve saved my ass. I’ve been trying endlessly for a solution until I’ve watched this video. Thank you!!
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
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 !
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
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.
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.
@@DavidNitzscheBell To filter dynamically, the @FetchRequest should be in a sub view.
oooooh, this looks really good. I definitely need it.....
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.
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!
Well done. Very, very nice! Thank you!
Wow 🤩
Great tutorial !!! help me a lot, may I ask how to count the total number of item after filtered ??
_ 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 🙌
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.
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.
I found Paul’s video very helpful: ruclips.net/video/kfsA87qRC3Y/видео.html
What is the data store changes though?
Is there any thread safety issues with passing the actual NSManagedObjects around?
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 💭
Muito bom o video, uma duvida como faria para processar o resultado e totalizar algum campo de valor...
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.
What if we'd like to filter with two or more filter keys ?
omg its so hard to get the searchbar added to the list with this method. any ideas??
Hi Paul. Thanks for the amazing tutorial. I have one error
Hi,
Is someone here to explain me why we used _fetchRequest and not just regular one?
Paul explained it in the video. It's very technical and tricky, but he explained it...
Great tutorial, but sadly dog-free this time! :)