它在快速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
答案 0 :(得分:0)
String
的 init
类重载double
方法。
let s = NSString(format: "%.2f", counter)