|
When I run my project file it gets the error in the @main file as it is in the title. I don't really know what's causing it but I wanna know why this is happening or what it means. I don't find any other errors exept for this, but at the same time I get the purple warnigs of "Accessing StateObject's object without being installed on a View. This will create a new instance each time." on those lines of code:
|
|
You need to pass an entity reference that you want fetched. If you imagine that you have several entities defined in your CoreData, you have to tell the function which one contains the data you are after. You have not shown your entity definitions (your CoreData setup), but I guess that you have an entity
|
|
Go to your @main class and add this line
|
|
your data controller
your @main class
|
|
@Greenamberred @AmitShrivastava Thank you for your answers. I tried those solutions but I didn't seem like working. When I add the @StateObject var dataController = DataController.shared , I got an error like this one: Type 'DataController' has no member 'shared' |
|
You need to add this line in your datacontroller class - |
|
Also just one more suggestion, if you are making a navigational jump and reaching your main View which can be ContentView() , make sure to add the environment object there as well, as if the context is not available then also such purple error show up, so make sure the DataController is a stateobject and also to add the environmentobject where ever you are navigating to contentview
|
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.