ios - Static property for type in Swift -
this question has answer here:
- static properties in swift 3 answers
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
Post a Comment