This is part of the code for a class method in the class BNRItem
, which returns an id
object. The author wrote that the key word self should be used when allocating, so that subclasses can also access this method. But wouldn't subclasses be unable to use this method because it returns an object of type BNRItem
? Could you tell me what I'm missing here? ;p
BNRItem *newItem = [[self alloc] initWithItemName:randomName
valueInDollars:randomValue
serialNumber:randomSerialNumber];
return newItem;