ios - Change text in label to "hi" after you click the button -



ios - Change text in label to "hi" after you click the button -

what wrong meant alter text in label "hi" after click button.

viewcontroller.swift:

// // viewcontroller.swift // helloswift // // created abdel rahman osman on 10/13/14. // copyright (c) 2014 abdel rahman osman. rights reserved. // import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var textgoeshere: uilabel! @ibaction func printtext(sender: anyobject) { var text = textgoeshere.text text = "hi" } override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } }

please help me prepare code new app development.

what doing creating re-create of text in label, discard , reassign new value, , discard 1 time again when variable goes out of scope.

the right way assigning text straight text property:

@ibaction func printtext(sender: anyobject) { textgoeshere.text = "hi" }

ios swift uiviewcontroller

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -