Chapter 2, page 55 randomPossession method


#1

The code for the class method randomPossession returns a pointer to a Possession object. Thinking along the same line as returning object pointer of type id in initializers, would it be better if the pointer is of type id instead of Possession? Here’s the code in the question:

[code]+(id)randomPossession
{

Possession *newPossession = [[self alloc] initWithPossessionName:randomName valueInDollars:randomValue serialNumber:randomSerialNumber];

return newPossession;
}

[/code]
Thanks.


#2

Yeah, this is good idea in practice. (Pedagogically, it would add too much confusion to the discussion around class methods - but I’m glad you picked up on it!)