Swift Compiler error while referencing existing variable -


i trying manually create placeholder text uitextview, , when try set placeholder text, swift compiler error. xcode telling me expected declaration pincontent first try set it's text value. here's code:

class firstviewcontroller: uiviewcontroller {  @iboutlet var pintitle: uitextfield!  @iboutlet var pincontent: uitextview!  @ibaction func createpin(sender: anyobject) {    }  override func viewdidload() {     super.viewdidload()     // additional setup after loading view, typically nib.      println(userlocation) }  // manually create placeholder text view pincontent.text = "description" // line error pincontent.textcolor = uicolor.lightgraycolor()  // change text properties of text view when user begins editing, types in normal black font func textviewdidbeginediting(textview: uitextview) {     if textview.textcolor == uicolor.lightgraycolor() {         textview.text = nil         textview.textcolor = uicolor.blackcolor()     } }  // if user leaves text view blank when they're done editing, re-set placeholder func textviewdidendediting(textview: uitextview) {     if textview.text.isempty {         textview.text = "description" // same error here         textview.textcolor = uicolor.lightgraycolor()     } }  override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }   } 

the problem seems want set text outside of scope of method or closure.
try this:

override func viewdidload() {     super.viewdidload()      // additional setup after loading view, typically nib.     // manually create placeholder text view      pincontent.text = "description" // line error     pincontent.textcolor = uicolor.lightgraycolor()     println(userlocation) } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -