If I try to use init, it will be a run time error, and not a compile time
error.
It there any way I can make Swift create the desired objc header file?
This is even worse if I want to create a singleton, and ensure that the
only way to access it, is through a static let on the class:
class Singleton: NSObject {
static let instance = Singleton()
private override init() {
super.init()
}
}
In Swift, I can't instantiate this class, since it has no internal/public
initializers. However, since it inherits from NSObject (which is necessary
to access it from objc), I can initialize it from objc, even though it's
private. Annotating it with @nonobjc doesn't help either.
Is there a reason why Swift doesn't automatically declare accessors from
the super class, that are either private or @nonobjc in the Swift subclass
implementation, as __unavailable?
Is there anyway I can enforce it using some (combination of) attributes?
If I try to use init, it will be a run time error, and not a compile time
error.
It there any way I can make Swift create the desired objc header file?
On Jun 8, 2016, at 7:06, Svein Halvor Halvorsen via swift-users <swift-users@swift.org> wrote:
This is even worse if I want to create a singleton, and ensure that the only way to access it, is through a static let on the class:
class Singleton: NSObject {
static let instance = Singleton()
private override init() {
super.init()
}
}
In Swift, I can't instantiate this class, since it has no internal/public initializers. However, since it inherits from NSObject (which is necessary to access it from objc), I can initialize it from objc, even though it's private. Annotating it with @nonobjc doesn't help either.
Is there a reason why Swift doesn't automatically declare accessors from the super class, that are either private or @nonobjc in the Swift subclass implementation, as __unavailable?
Is there anyway I can enforce it using some (combination of) attributes?
If I try to use init, it will be a run time error, and not a compile time error.
It there any way I can make Swift create the desired objc header file?