iOS 15: One-to-many relationships with @FetchRequest and SwiftUI - Core Data SwiftUI Tutorial 7/7
HTML-код
- Опубликовано: 13 окт 2024
- Download the completed project here: github.com/two...
Other parts in Project 12:
Introduction: www.hackingwit...
1. Why does \.self work for ForEach?: • iOS 15: Why does \.sel...
2. Creating NSManagedObject subclasses: • iOS 15: Creating NSMan...
3. Conditional saving of NSManagedObjectContext: • iOS 15: Conditional sa...
4. Ensuring Core Data objects are unique using constraints: • iOS 15: Ensuring Core ...
5. Filtering @FetchRequest using NSPredicate: • iOS 15: Filtering @Fet...
6. Dynamically filtering @FetchRequest with SwiftUI: • iOS 15: Dynamically fi...
7. One-to-many relationships with Core Data, SwiftUI, and @FetchRequest
Challenges: This video
Wrap up and challenges: www.hackingwit...
You can find the full set of videos, along with transcriptions, challenges, tests, and more, in my free 100 Days of SwiftUI course: www.hackingwit...
Watch the full 100 Days of SwiftUI playlist here: • Hacking with iOS: Swif...
One man has many dogs.
Many dogs have one man.
Another great video. Do you have an example of a core data and a form supporting a many-to-many relationship?
Great tutorial. Do you have a many to many example? One where you might have to keep additional in the intermediate table? Like Recipe/Ingredient with an intermediate table for amount, or User/Rating/Restaurant, etc.
Love the dogs!
Paul, shouldn't those convenience properties be called unwrapped* as you are actually unwrapping the optional?
I went back and forward on the naming a few times, because although I'm unwrapping them I'm not *just* unwrapping them - it's not like a force unwrap, but instead some wrapper code that provides a default value. I've used unwrapped* elsewhere a few times, so it's not like I'm firmly committed to the choice 🙂
@@twostraws I went with unwrappedWrapped
Such a great tutorial, you helped me so often!
I am in the mood for candy now 🍬… those dogs though, wonderful 😊 Love the videos 👍🏻
OMG. this video is mind-blowing
Such a great tutorial, and you are the best teacher. Thank you so much🥰
Thx for this. I followed this tutorial using swift playground on the iPad. It works fine, but is it possible to set Contraints for Entity manually, not using Xcode ?
If I want to store URLs and UUIDs in Core Data, what should I nil coalesce to when creating those computed properties? A new empty URL instance (i.e URL(fileWithPath: "") and a new UUID() instance respectively?
Thank you, that's such great tutorial!
Thanks so much for your tutorial! It helped me lots
Why did Paul call those variables wrappedShortname (etc) rather than unwrappedShortname? Thanks.
Couldn't you have the classes automatically created and create an extension class for the object and still use Codegen = class definition?
Insanely helpful tyvm :D
Wouldn't it be better to put the wrapped properties as an Extension in another file so it doesn't get rewritten?
Thanks you sooo much foir this awesome great video!
Hi, how to fetch only the Countries without the relationship entities?
How many treats do they get everyday?
How can I create data and display it when the app starts, without having to click the button first?
Anywhere where your code already runs without an explicit interaction (like a button press) would work. An example would be the ContentView’s initializer, or in CoreDataProjectApp before ContentView is initialized. Just remember to remove that code after it runs once, otherwise you’d be attempting to create and save that data on each run
@@nabs Thank you for this! I tried messing around with the initializer before asking this question but I can't get a full grasp on how to use it with my data model.
Hola. Could you make a video on how to update/delete an entity?
He did before
Revise bookworm series
@@MoAdel92Could you please share the link? I looked everywhere but couldn’t find it.😂
constraints failed to work in Xcode Version 14.1 beta (14B5024h) sometimes, I added constraints for shortName but I can still see a bunch of entries with the same short name, I even downloaded your project 12 from github and directly run on my mac, still no luck. But previously it worked perfectly for singers with same names, really strange.
Same thing here. Did you get a solution?
@@iurii513 Be sure to update the Persistence file generated in Xcode 14.0+. I added the self.container.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump to line 55, after the container...MergesChangesFromParent = true in the initializer.
@@JonSweeney26 what do you mean to line 55? It isn't working for me and I can't find any information regardless the merge policy getting old. Could you be more specific? Thanks!!
To your DataController file, add the following code after your closing brace for container.loadPersistentStores (probably line 15)
self.container.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
I thought I had the same but I missed the part where he added try? moc.save() at the end
Is there a working code for download available?
how to clean all the errors and warnings?
Command + Shift + K
Well, well, well....Who would have thought that I'd learn something about the origin of candy bars in a video about SwiftUI???? I was all ready to "correct" you about the origin of Mars, Twix and KitKat (I'm from the US and, of course, *everything* was invented in the US, right? ) but life has taught me to look things up first. And, lo and behold, invented in UK!!! So, at least I can blame the UK for being the US's origin story for fascination with junk food. ;)
Power of Hungry Dogs lol 🤣