Multiple errors in Xcode

Hello, today I was making an app the general idea of it is that there is a counter that counts the number of times the button has been pressed, and the app worked totally fine and as good as I expected it to be, therefore I decided to make a reset button when I added the reset button Xcode showed me multiple problems which I didn’t understand, here’s a screenshot

I don’t understand how it’s not finding

when it’s a function
the code is in the screenshot but If you want me to send the code as text just tell me!

I really appreciate any help you can provide!


Your reset function is outside of the ContentView struct which is why the compiler is saying that it “cannot find AlTasabih in scope”.

Move it up to just below the closing brace of your Tasbih() function.

Also move the Button(“Reset”) up to just below the last Spacer().

Your ContentView code should then look like this:

struct ContentView: View {
    @State var AlTasabih = 0

    var body: some View {
        VStack {

            Button {
            } label: {
                Image(systemName: "button.programmable")

            Button("Reset") {

    } // Closing brace of the body property

    func tasbih() {
        AlTasabih += 1

    func reset() {
        AlTasabih = 0
} // Closing brace of the ContentView struct

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {

Thank you very much!