创建一个继承Objective-C中对象列表的类

时间:2013-10-12 14:20:16

标签: ios objective-c

来自.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提供的语法糖比我不会反对的那么多。

1 个答案:

答案 0 :(得分:1)

我认为这个子类太多了。子类应该用于向超类添加功能。你应该只创建一个UIImageViews的NSMutableArray