0

I just started writing a new app in Xcode beta 6 and I need to write an if statement for my code to work but I keep getting the error Expected declaration no matter where I put the if statement. my code is

let randomNumberColorPicker = arc4random_uniform(4) + 1



 if randomNumberColorPicker == 1 {
}

override func viewDidLoad() {
    super.viewDidLoad()
       }

What can I do to actually make this work?

Lkopo
  • 4,798
  • 8
  • 35
  • 60
Ryan
  • 1
  • 1
  • this code looks okay to me. your problem is coming from outside of this code block. what's above your "`let randomNumberColorPicker`" line? – Michael Dautermann Sep 13 '14 at 19:25

1 Answers1

0

From what I can see, your code is not in a function. Move your code into viewDidLoad:

override func viewDidLoad() {
    super.viewDidLoad()
    let randomNumberColorPicker = arc4random_uniform(4) + 1
     if randomNumberColorPicker == 1 {
       println("true")
    }else{
        println("falseMove your code int viewDidLoad")
    }
 }
weePee
  • 895
  • 1
  • 8
  • 23