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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -