static var in Objc replaced by statemachinetype in swift

typealias StateMachineType = ()->Int

func makeStateMachine(maxState:Int)->StateMachineType{
 
  var currentState:Int = 0
  return {
    currentState++
    if currentState > maxState{
      currentState = 0
    }
    return currentState
  }
}

Tags: