I’m not 100% sure what’s going on here but there’s seems to be some confusion about designated initialisers. SKNode’s designated initialiser is
-init
. SKLabelNode doesn’t change that,
-initWithFontNamed:
is not labelled as a designated initialiser, so that leaves its designated initialiser as
-init
. That means that you’re creating a designated initialiser that calls super’s convenience initialiser, which isn’t allowed.
As to why the compiler hasn’t complained about this at compile time, I’m not sure. Looking at the Swift interface to SKLabelNode, it shows this:
public init(fontNamed fontName: String?)
implying that Swift thinks that SKLabelNode’s designated initialiser is
-initWithFontNamed:
, which is at odds with the Objective-C header. It’s possible that Swift has some SpriteKit specific knowledge here.
You should file a bug about this, so that someone who knows more about this than I do can work out what’s going wrong. Please post your bug number, just for the record.
As to a workaround, you can make things work simply by overriding
-init
, not
-initWithFontNamed:
.
import SpriteKit
class SKLabel : SKLabelNode {
override init() {
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"