0

I have an NSPointerArray and in one of my methods, I want to access the objects stored in that NSPointerArray (as I have to use one of the object's properties). I don't want to create a new NSArray with the allObjects method as that will be redundant in my program. Right now, I'm doing the following which uses a lot of memory? (Sorry, I'm a noob).

-(void) print
{
    for (int i=0; i<[list count]; i++){
        NSLog(@"%@",[((__bridge Song*)[list pointerAtIndex: i])  title]);
    }
}

Thanks

Alex Cio
  • 6,014
  • 5
  • 44
  • 74

1 Answers1

-1

It looks like your problem is already solved. Wanted to mention its easier to loop over your NSPointerArray with a foreach loop. In this case you do it like this:

-(void) print {
    for (Song *s in list){
        NSLog(@"%@", [s title]);
    }
}

This way you can concentrate on the object instead of using the integer of your loop.

Alex Cio
  • 6,014
  • 5
  • 44
  • 74