NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

what do these errors mean ? pls help xd

Forums > SwiftUI

hi ! im new to swiftUI and this is my first time developing an app by myself :D i want to make a cookie clicker sort of game ( but instead of cookies its pie. ive already gotten hung up on trying to get the counting system to work. i have code that works , but it uses @State which , to my knowledge , doesn't save the variable (the count of pies) after closing the app. i was trying to use wrapped value (not sure the technical name :sad:) but it keeps throwing me some errors ? out of all of my reaserch ive not been able to figure out what they mean or how to solve them. so , as if you were explaining to a 5 year old , what do these errors mean & how do i solve them ? i've attached an link to an image of my code below - i couldnt figure out how to embed it - thanks !!!


I assume you're coding in the Playground app on an iPad. To copy your code: Press any part of the text area for about 2 seconds. When you release your finger, a menu should pop up.
Tap "Select All". This should cause your entire code to be highlighted blue. Tap the highlighted area very briefly. In the menu that pops up, select "Copy". Now you can paste it into your web browser.

Regarding your error messages, it looks like you copied this code from somewhere because it includes "wrappedValue" and "where", which are advanced concepts that are both unnecessary for your app and too complicated to explain until you learn more basic concepts.

I suggest you start with the (free!) "100 Days of SwiftUI" lessons on this website. If that seems like too much to tackle, a fun but very helpful tutorial is a book that you can read in the Books app called "Develop In Swift Fundamentals", published by Apple Education. Be sure to get the Xcode 13 version, which is the latest.


I will sedond the "learn the basics". Things that used to baffle me are now simple and easy to understand. I had a little knowledge and started writing an app. All of a sudden stuff came up that eiter I did not know, problems were cause by my misunderstand, parts of the code looked like magic to me and I would stick these totems, like @State, in my code without knowing what they did.

I went through the 100 days of SwiftUI course and a lot of things cleared up, I now what @State does, and I wrote code and "learned" things about the environment. You may think you know something but write a simple app to test and see if it does what you think it does and sometimes you find Oh, it doesn't work like that, it does this.

Just a little bit ago I was floundering, trying to use the tiny bit of what I knew to understand the huge world of Swift and the iPhone. Now, I am a little better.

One problem I had was I kept being tolt to write these simple useless apps. The app I wanted to write was useful. Write the simple ones and you learn the stuff that you can put together to write the useful app. You write the simple apps not to have an app that will pick from a list and not save that pick for the next time you run. You learned how to pick from a list. Another simple app saved some data, again not useful data. A third app showed you how to pop a sheet. Now you can pop a sheet, pick an entry from that list and save the selection for the next time the app runs, something your useful app might do.

I started out with an app in my head I wanted to write. I looked at an example that let me select from a list. Now I whated to pop a second view and save stuff to disk and a whole lot more. You can not start knowing nothing and write a complex app. You need to learn how to do simple stuff and put that stuff together to build your app. Alsong the way you learn how SwiftUI works and you can fit your vision to how it works. It's horrible if you go I want to do A and SwiftUI does not do A. Instead say I want 1 to happen and with what SwiftUI does, which you learned in the simple, "useless" apps, you simply do B, C, and D and then 1 is done.


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.