The Class method randomItem


#1

In the class method +(id)randomItem we have:

    BNRItem *newItem = [[self alloc] initWithItemName:randomName
                                       valueInDollars:randomValue
                                         serialNumber:randomSerialNumber];
    return newItem;

Ok to the “self alloc” instead of “BNRItem alloc”, so to a subclass of BNRItem we can use randomItem too…
But if we send a message randomItem to a subclass of the BNRItem class the result will be an BNRItem object (BNRItem *newItem … return newItem) and not a subclass object, right?

It will be like if we do this:

The Xcode acepts this line of code, but we cant acess the addObject method because the items object is a NSArray…
So if we create an instance of a BNRItem subclass with the randomItem method we will not be able to acess the new methods of the subclass?
How Objective-C handles this situation?