[NSArray count]: method only defined for abstract class. Define -[IngredientsMutableArray count]

来源:互联网 发布:阿里云制作服务器镜像 编辑:程序博客网 时间:2024/06/10 13:18

类似这样的问题~

出错原因:

NSArray 和 NSDictionary 都是簇类,一般不建议写一个类去继承他们。

解决:

如果非要继承,一定要准确的重写这些基本的方法:

insertObject:atIndex:removeObjectAtIndex:addObject:removeLastObjectreplaceObjectAtIndex:withObject:
更好的选择:

    1,Use a category

    2,Create a new class that has anNSArray as a member variable


参考:
http://stackoverflow.com/questions/5937870/why-doesnt-my-nsmutablearray-subclass-work-as-expected

0 0
原创粉丝点击