ios - Xcode not recognizing declared variable? -
this question has answer here:
i have created new class within controller file such :
import uikit class firsttableviewcontroller: uitableviewcontroller { class sport { var name: string = "sport name" var branches: nsarray = [" branches of sport"] }
now when try create new object class, works expected:
var americanfootball = sport()
however when try access 1 of properties class change, doesn't recognize new object:
whats issue ?
you should access property inside function.
import uikit class firsttableviewcontroller:uitableviewcontroller { class sport { var name: string = "sport name" var branches: nsarray = [" branches of sport"] } var americanfootball = sport()//this property of firsttableviewcontroller override func viewdidload() { americanfootball.name = "another" } }
Comments
Post a Comment