How to call methods of base class in subclass on iOS?

I’ve tried code as below, but nothing works:

public class TestClass : Foundation.NSMutableArray{
    
    public static void test(){
        var t1 = new TestClass();
        // #1 Terminating app due to uncaught exception 'NSInvalidArgumentException',
        // reason: '*** -[NSArray count]: method only defined for abstract class.  Define -[TestClass count]!'
        t1.doSth();

        // #2 Terminating app due to uncaught exception 'NSInvalidArgumentException', 
        // reason: '*** -[NSMutableArray initWithCapacity:]: method only defined for abstract class.  Define -[TestClass initWithCapacity:]!'
        var t2 = new TestClass withCapacity(4);

        var t3 = new TestClass(4);
    }

    public TestClass(){
    }

    public TestClass(int capacity)
    {
        // FAILED as #2
        base.initWithCapacity(capacity);
    }

    /*
    public TestClass(int capacity)
    // FAILED as #2
    : base withCapacity(capacity)
    {
    }
    */

    public int doSth(){
        return base.count - 1;
    }
}

In general, base. is the proper syntax.

But note that NSArray is a class cluster that does magic stuff under the hood. Subclassing class clusters is not for the feint of heart and ha slots of restrictions —which is probably what you are running into. I’d suggest to think long and hard on what yon want to achieve, and if subclassing an NSArray-family class is the best option to do so.

Thanks for your suggestion! I’m actually new to Cocoa programming.

I’ve found the better solution is just making NSMutableArray as a class member instead of subclassing it.

The reason why I was trying to subclass NSMutableArray is a problem recently found in my home-made List(similar to Sugar.Collection.List) which is implemented by mapped class:
Because NSArray can’t store null value, so we have to use a helper method to ensure all setter/getters are null-safe. But you can’t do that for INSFastEnumeration interface, because mapped class can’t do override thing.