|
Hi All, I thought to challenge myself in that I'd modify the candy project (Project 12 of 100 days of SwiftUI) to learn more about Core Data. Here is what I managed so far: I've modified the ContentView.swift file so that the countries appear as rows on my form with a navigationlink to custom DetailView.swift. The DetailView does list the respective candies. I can also add new countries using a toolbaritem -> opening a custom AddCountryView.swift file as a sheet. This works. Saving the new countries also works fine. They do appear in m main view afterwards. Here is what doesn't work, though: Adding a new candy. Once inside DetailView.swift I can tap the toolbarItem to create a new candy using a custom AddCandyView. So here is the issue: Either saving the new candy doesn't work - or letting in appear in DetailView afterwards. I'm not exactly sure which of these two is the issue, I'm afraid. However, I've been working on this for two days, but the nearast I could get to is an Error "Missing argument for parameter "country" in call." on this: ".sheet(isPresented: $showingAddCandyView, content: { AddCandyView()" in DetailView. Unfortunately, I'm not yet experienced enough to have a clue of what to insert here. Next to that I seem to be to stupid to insert a screenshot here... Anyway, I would be greatful if anyone could push me in the right direction with this! Many Thanks! Pascal
|
|
hi, just a few quick comments ...
hope some of this might be helpful, DMG |
|
Hi DMG, First of all many thanks for your quick reply! Unfortunately, your suggestions didn't help with the error message. Still the same on that. I should have added that I got the @StateObject idea from a YouTube tutorial, which teaches how to use one-to-many relationships in their app - though it's build slightly different (the new item gets created using a TextField above the list instead of in a seperated view. https://www.youtube.com/watch?v=xgPlJXTfiNA That, and that I'm still learning the ins and outs. Anyway, again many thanks for your help! Pascal |
|
UPDATE: I changed the app to directly add candies ON DetailView() and that works just fine (But that's not a workaround I can life with). So it's clearly something in passing the data around when saving from AddCandyView() Can anyone with more experience than I have spot the missing link? Thanks, Pascal |
|
Just to let you know: I was finally able to fix this issue after a good week. Here is the solution just in case anyone else stumbles over this in the future:
If you asked me I'd swear to have tried "country: country" over and over again. Looks like I couldn't see the forest for the trees anymore. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
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.