Boolean values in Swift are true
and false
, YES
and NO
is used in Objective C.
So in your stopRunning
method for instance, you should write:
@IBAction func stopRunnng(sender: UIButton)
{
tmrRun invalidate()
btnGo.userInteractionEnabled = true
btnStop.userInteractionEnabled = false
sliSpeed.userInteractionEnabled = true
}
(sidenote, you don’t need the ;
in Swift either)
About the void function. In Swift you write the return type AFTER your method declaration, starting with a ->
. Like so:
func takeABound(parametersWouldGoHere) -> ()
For a void method you can write ()
or Void
or, as you’ll often do, don’t write anything at all.
func takeABound(parametersWouldGoHere)
As it says in “The Swift Programming Language” in the chapter about functions
Because it does not need to return a value, the function’s definition does not include the return arrow (->) or a return type.
You can read more about functions, booleans and the like in “The Swift Programming Language”, there is a nice chapter called “A Swift Tour” that will introduce you to many of the basic things.
Hope that helps
1
solved Swift Version 2 Bool [closed]