1

I'm trying to work with Swift 2, but i have troubles with variables. When I declare a var, Xcode shows this enter image description here

I try with another code like

if let touch = touches.first as? UITouch { // ... }

But is the same problem.

UITouch is not the only one with the problem, other variables too.

What i can do for fix it?

Thanks.

3
  • What do you mean by _? Commented Sep 16, 2015 at 4:30
  • Is the suggestion, the original code is let touch = touches.first as UITouch Commented Sep 16, 2015 at 4:34
  • Yes, try it. It's warning not an error. Commented Sep 16, 2015 at 4:36

1 Answer 1

2

It's because you have never used touch again in you code. It's an unused variable. Either consider removing it or you can fix it using the above fix.

This warning will go away once you use the touch variable.

e.g.

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { let touch = touches.first as UITouch! print("\(touch)") } 

In above case touch is used in print method and hence there won't come any warning.

Sign up to request clarification or add additional context in comments.

2 Comments

Good programer always keep ZERO warnings. Welcome to the elite group :)
Thank you very much, I appreciate it. I try to do my best

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.