Swift Random Function
Solution 1:
Assuming I'm understanding your question correctly, you want this:
func createObstacle() -> () -> () {
var obstacles = [obstacle1, obstacle2, obstacle3]
var randomObstacle = Int(arc4random_uniform(UInt32(obstacles.count)))
return obstacles[randomObstacle]
}
Check out the documentation section about functions: https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/Functions.html#//apple_ref/doc/uid/TP40014097-CH10-XID_243