I’m writing an NSArray category to include the -objectAtRandom message that returns an object from a random index (something similar to Python’s choice).
Should I autorelease this object before returning it? I believe I shouldn’t, but I’m not sure…
According to the normal memory management rules, no, you should not. Since you’re presumably using
objectAtIndex:to return the object, you don’t need to do any memory mangement of your own.