-1

のサブクラスであるカスタム クラスがありSKSpriteNodeます。spriteNodeWithColor:size:を返すメソッドをオーバーライドしようとしていますinstancetype。私はこれを試します:

 -(instancetype)initWithColor:(UIColor *)color size:(CGSize)size{
     self.color = color;
     self.size = size;

     //do other setup stuff here
     return self;
}

しかし、毎回クラッシュします。よろしくお願いいたします。

4

1 に答える 1

5

あなたは呼び出す必要がありますsuper

- (instancetype)initWithColor:(UIColor *)color size:(CGSize)size {
    self = [super initWithColor:color size:size];

    if (self) {
      // do other setup stuff here
    }

    return self;
}
于 2014-01-05T22:03:24.140 に答える