Fix memory leak when breaking out of a for-in loop

Use an autoreleased NSMutableArray rather than id[] to keep the objects alive so that they eventually get deleted if the caller breaks out of the loop.

@alazier @jpsim 
Do we need the @autoreleasepool here as well?