-3

Somehow the print() method is not recognized anymore, I even tried reinstalling Xcode but no luck!

Showing the error

1
  • You need to put it inside something that gets executed, like a function. Commented Jul 7, 2020 at 22:03

2 Answers 2

2

Any print statement outside the body of function is not allowed . You can use print statement either inside the viewDidLoad function or you can make your custom function and then use it.

You can use it inside your function Like this.

func CustomFunction()  {
    
    print("Hello")
}
Sign up to request clarification or add additional context in comments.

Comments

0

Try moving print("Hello") into your viewDidLoad() method. Place it between the curly braces following your viewDidLoad() method. As Phillip said, it must be written inside something that is executed, such as this function.

Your code should then look something like this:

    override func viewDidLoad() {
        super.viewDidLoad()

        // Write your code here...
        print("Hello")
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.