-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 回答