|
Is this the correct way to to use coredata with the new App protocol? My app works like this but im a beginner so dont know if this is making some bad performance or if the app will crash in future when the coredata model get more entrys? See down: ContentView is the navigation menu, and the views i navigate to from contentview can use the coredata through the @Environment of managedObjectContext now so it seems like all is working..
|
|
I have the same question. Similarly would like to know where to put Scene Delegate code that deals with configuring core data like:
|
|
You might want to add an .onDismiss(perform: saveContext) after the .environment line on the ContentView() |
|
I'm on a similar journey today with learning Core Data and the new SwiftUI Life Cycle. A few things I've found helpful:
|
|
If you wonder where to put the line: open the
|
|
Great topic. I'm learning app programming using swift and hackingwithswift has been great. I placed the mergepolicy as @multitudes suggested addapting the template and I don't get the needed behavior. The one side field gets repeated still using the following code to build the list.
I inserted the merge policy like this.
|
|
Resolved...I found my issue above. I had forgotten to place (or thought I had already placed) an attribute contraint for for the entity. |
|
@Hamztr to the gent at the very start, you are missing a perenthesis after your .environment line; question from me regarding the trump merge policy, where is best to put it in this stack? the examples above use the boilerplate that comes by checking the include core data checkbox. I prefer to do things programaticaly, i dont know why i do, it makes life much much harder!
|
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.