无法找到接受所提供参数的“init”的重载(swift)

时间:2014-09-17 08:04:56

标签: swift

它在快速beta4中工作,现在我有GM版本 但这个错误说你好 我怎么解决这个问题?

"无法找到' init'接受提供的参数"分为两部分

var timer = NSTimer()
var counter : Double = 7.0

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    labelCounter.text = String(counter)       <- error here
}

@IBOutlet weak var labelCounter: UILabel!

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func startCounterPressed(sender: AnyObject) {
    timer.invalidate()
    timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}

func update()   {
    sth cool
    }

@IBAction func pauseCounterPressed(sender: AnyObject) {
    timer.invalidate()
}

@IBAction func stopCounterPressed(sender: AnyObject) {
    timer.invalidate()
    counter = 7.0
    labelCounter.text = String(counter)           <- error here

1 个答案:

答案 0 :(得分:0)

String

init类重载double方法。

let s = NSString(format: "%.2f", counter)