importUIKit classViewController:UIViewController{ @IBOutletweakvardisplay:UILabel! varuserIsInputingDigit:Bool=false @IBActionfuncappendDigit(sender:UIButton){ letdigit=sender.currentTitle! ifuserIsInputingDigit{ display.text=display.text!+digit }else{ display.text=digit userIsInputingDigit=true } } overridefuncviewDidLoad(){ super.viewDidLoad() //Doanyadditionalsetupafterloadingtheview,typicallyfromanib. } }
来自: https://itunes.apple.com/us/course/developing-ios-8-apps-swift/id961180099