在 Objective-C 中将对象初始化为其子类; / iPhone SDK
我有一堂课,我正在其中初始化我制作的另一个课程。我制作的另一个类有一个子类,仅进行了一些更改(对 init 方法没有任何更改)。我想知道如果我尝试这样做可以吗?代码看起来像这样。
其中一种情况: self.shapeLayer = [[UMShapeLayer alloc] init]; 在不同的情况下: self.shapeLayer = [[UMShapeLayerOnslaught alloc] init];
如果这会引起问题,并且有另一种方法可以做到这一点,请有人告诉我。
i have a class, in which i am initialising another class that i have made. the other class that i have made has a subclass with only a few changes (none to the init method). What i am wondering is will it be ok if i try to do this. the code looks something like this.
in one of the cases:
self.shapeLayer = [[UMShapeLayer alloc] init];
in a different case:
self.shapeLayer = [[UMShapeLayerOnslaught alloc] init];
if this will cause problems and there another way that i can do this, please could somebody tell me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不再需要知道。我抽出时间测试了我正在使用的库,它确实有效
No longer need to know. I got round to testing the library that i was using, and it does work