Where is a memory leak in my for ... in a loop with addObject

It looks like a memory leak occurs in the following loop:

NSMutableArray *array1 = [[NSMutableArray alloc] init];
for(SomeClass *someObject in array2){    //has already been populated;
    if (someObject.field == desiredValue){
        [array1 addObject:someObject];
    }
}
//EDIT:
//use array1 for very secret operations
[array1 release];

Any ideas why?

+5
source share
1 answer

Are you freeing all your saved properties in SomeClass? Ensure that in dealloc release all stored properties. Make sure SomeClass is not leaking.

+1
source

All Articles