You cannot initialize an instance property with the value of another property, because self
is not available until all instance properties have been initialized.
Even moving the properties initialization in an initializer doesn't work, because getKey
relies on webUrl
, so getKey
cannot be initialized until itself is initialized.
I see that webUrl
is a constant, so maybe it's a good idea to make it a static property - classes don't support statics as of yet, so the best way is to use a private struct:
class ApiUrls {
private struct Static {
static let webUrl: String = "192.168.0.106:8888"
}
var getKey: String = Static.webUrl + "dev/sys/getkey"
}
Also, unless you have a good reason, it's better to use swift strings and not NSString
.