iphone - Ambiguous use of "value" while implementing UIStepper -
i trying implement simple stepper reflects value onto label. while using "int(sender.value)" getting error "ambiguous use of value"
// viewcontroller.swift // stepper // // created prabhu konchada on 19/06/15. // copyright (c) 2015 prabhu. rights reserved. // import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var steppervalue: uilabel! @iboutlet weak var outputlabel: uilabel! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func steppertap(sender: anyobject) { self.outputlabel.text = string(int(sender.value).description) } }
you can follows :
@iboutlet var lblstep: uilabel! @ibaction func steppressed(sender: uistepper) { lblstep.text = sender.value.description }
else have convert anyobject
uistepper
as
var stepcontrol : uistepper = sender as! uistepper
as :
@ibaction func steppertap(sender: anyobject) { var stepcontrol : uistepper = sender as! uistepper self.outputlabel.text = stepcontrol.value.description }
whole code version 6.1 have change as! 6.3.2:
import uikit class viewcontroller: uiviewcontroller { @iboutlet var lblstep: uilabel! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func steppressed(sender: anyobject) { var step : uistepper = sender uistepper lblstep.text = step.value.description } }
Comments
Post a Comment