ios - Setting the text of a UILabel -
i'm using new xcode beta (which might issue coming from).
i followed online tutorial, making simple counter app.
the issue have line followed below:
outputlabel.text = "the button has been clicked \ (currentcount) number of times"
the whole code followed:
class viewcontroller: uiviewcontroller { @iboutlet weak var outputlabel: uilabel! var currentcount = 0 override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func addonebutton(sender: uibutton) { currentcount = currentcount + 1 outputlabel.text = "the button has been clicked \(currentcount) number of times" outputlabel.textcolor = uicolor.redcolor() }
the issue is:
use of unresolved identifier
outputlabel
why can't code find outputlabel
?
it must this,
let outputlabel = uilabel(frame: cgrectmake(0, 0, 100, 30)) outputlabel.text = "the button has been clicked \(currentcount) number of times"
you missing declaration of label.
or
if using via @iboutlet, make sure have connected outputlabel
in nib/storyboard file.
or
recheck declaration, might different outputlabel
, using outputlabel
.
Comments
Post a Comment