I’m getting an odd compile error in a pretty basic scenario: I’ve got a class hierarchy with a boolean “online” property that’s mutable but not externally settable. A subclass wants to add a ‘didSet’ observer to do something when the value changes:
public class Peer : NSObject {
public internal(set) dynamic var online = false
}
public class OnlinePeer : Peer {
public internal(set) override dynamic var online: Bool { // ERROR!
didSet {
println("set online")
}
}
}
The error says “Setter of overriding var must be as accessible as the declaration it overrides”, and the suggestion is to delete “internal (set)”. But this is backwards — the code is correct as written (I think), but removing “internal (set)” would make the setter public, which is different from the inherited access and not what I want.
(The didSet block doesn’t seem to be the source of the problem; I get the same error if I take it out.)
What’s going on here?
—Jens
PS: Xcode 6.3.2, iOS target