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

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World