I have two questions, please:
1) what is the meaning of "scope"? Context: "The pointer to the Possession instance is lost when the scope of randomPossession runs out, but the object still has a retain count of 1." Do you just mean when the randomPossession method competes? 2) for the class method randomPossession, I think I understand the concept of autorelease from your description. The method created the instance, it needs to get rid of it AFTER it is added to the NSMutableArray. So after you described the issue with multiple ownership, I expected the line of code return newPossession;
// to be followed by the line
Instead, you have substituted the code return [newPossession autorelease];
In “main”, the NSMutableArray needs the randomly generated new Possession. So you want to return the newPossession from the method. The way you have written it, you are returning the results of the autorelease function. To me the result would be “waiting to go to instance heaven”! What will the array you are generating do with that??
In essence, what I am asking is: what is returned to the addObject method from “return [newPossession autorelease]” ? I fear my question will be gibberish to you, but I’ll risk it.