Your method should set the array to autorelease and then the caller should retain the returned array. So the method is no longer responsible for the array, the caller is.
The objects in the array will be retained by NSMutableArray, so you should set them to autorelease so they don't leak.
- (NSMutableArray*) calleeMethod
{
// this method is retaining the array temporarily
// someone else is responsible for retaining it
NSMutableArray * newArray = [[[NSMutableArray alloc] init] autorelease];
// add some objects
for (int i = 0; i < 10; i++)
{
// autorelease these objects because newArray will retain each item and
// is responsible for the items
FooObject * newFooObject = [[[FooObject alloc] initWithNumber:i] autorelease];
[newArray addObject:newFooObject];
}
return newArray;
}
- (void) callerMethod
{
// retain the returned array, because we own it
mNewArray = [[self calleeMethod] retain];
// do stuff
// make sure you explicitly release mNewArray later (probably in the dealloc)
}