I currently have a variable in a class open var deviceIdentifier: String? and would like to deprecate the setter only turning it into open private(set) var deviceIdentifier: String?
Is there any way to do that? I tried to put both lines in but that is obviously a conflict Xcode doesn't like.
@available(*, deprecated)
open var deviceIdentifier: String?
open private(set) var deviceIdentifier: String?
The compiler is happy if I change it to a computed variable but I'd like to avoid that. Is this the only way, and will this work as expected?
private var _deviceIdentifier: String?
open var deviceIdentifier: String? {
get {
return _deviceIdentifier
}
@available(*, deprecated)
set(newValue){
}
}
It seems the only way to do this right now is with a computed variable, but it does work as expected.
//TODO: put back to non-computed variable when making set private
private var _deviceIdentifier: String?
open var deviceIdentifier: String? {
get {
return _deviceIdentifier
}
@available(*, deprecated)
set(newValue) {
_deviceIdentifier = newValue
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With