来自.NET背景,我曾经制作过看起来很像这样的类:
MyClass
Inherits List(Of SomeOtherClass)
我在Objective-C中试图做到这一点感到抽烟。我想要一个类,它是UIImageViews的集合。
我试过了,这是错误的(它是从NSArray继承的):
- (id)init
{
//I know I'm not using an imageview here, this was just a proof of concept
self = [super initWithObjects:[UIImage imageNamed:@"btnSideMenu"], nil];
if (self) {
}
return self;
}
集合是固定大小的,因此不需要可变。但是,如果使用NSMutableArray提供了比我更多的语法糖,我将不会反对它。
我认为为此的子类是过多的。子类应用于向超类添加功能。您应该只制作一个UIImageViews的NSMutableArray
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句