In my app, there are objects that go in certain directions on the screen based on variables that are stored into an NSMutableArray. To save memory, once these items go off the screen, I would like to remove them from the array and the view. Here is my code, but it doesnt seem to be working. I have tryed NSLogging or putting in breakpoints to see if it works, but even when the objects go off of the screen, it doesnt do anything. Could someone please tell me what to do to fix it? Thanks in advance.
Code:
for(int control=0;control<[randomObjectArray count];control++){
UIImageView *randomObject = [randomObjectArray objectAtIndex:control];
if(randomObject.center.x==0){
[randomObject removeFromSuperview];
[randomObjectArray removeObjectAtIndex:control];
randomObject = nil;
NSLog(@"Removed randomObject from the Array");
}