ios - Access static variable from non static method in Swift -
i know cannot access non static class variable within static context, other way around? have following code:
class myclass { static var myarr = [string]() func getarr() -> [string] { return myarr }
however, when try compile this, error myclass not have member named myarr
. thought static variables visible both static , non static methods, don't know going wrong.
i on macbook running os x yosemite using xcode 6.3.
you need include class name before variable.
class myclass { static var myarr = [string]() func getarr() -> [string] { return myclass.myarr } }
Comments
Post a Comment