在 Objective-C 中将对象初始化为其子类; / iPhone SDK

发布于 2024-09-16 10:46:32 字数 273 浏览 0 评论 0原文

我有一堂课,我正在其中初始化我制作的另一个课程。我制作的另一个类有一个子类,仅进行了一些更改(对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不念旧人 2024-09-23 10:46:32

不再需要知道。我抽出时间测试了我正在使用的库,它确实有效

No longer need to know. I got round to testing the library that i was using, and it does work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文