ios - Static property for type in Swift -


this question has answer here:

i want declare static property unknown on type gpslocation

class gpslocation: nsobject {   var lat: nsdecimalnumber = 0   var lng: nsdecimalnumber = 0   class var unknown:gpslocation = gpslocation(lat: 0, lng: 0)    init(lat:nsdecimalnumber, lng: nsdecimalnumber){        self.lat = lat        self.lng = lng   } 

}

i "class variables not yet supported"

how can declare static property in swift?

i'm not sure you're trying do, naming, you'd better off using optional gpslocation indicate unknown position rather comparing illegal value (which actually, in case, legitimate gps location)

this intended usage of optionals, indicate has invalid or unknown value, without trying come otherwise invalid value stuff them with.

in case, you're trying done can done implementing getter in method:

class var unknown:gpslocation { return gpslocation(lat: 0, lng: 0) } 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -