I'm doing my last bit of memory management tidying and there's something I don't understand. I've checked all the documentation, Stack Overflow, etc. but still don't get it. I suspect it's to do with arrays.
I have an NSMutableArray as an instance variable which I use to hold objects created from objects in another array.
-viewDidLoad initialises the array as follows:
self.photoAlbum = [[NSMutableArray alloc] initWithCapacity:100];
It then calls a method which populates them.
int i = 0;
for (Gem *gem in self.entityArray) {
NSString * filePath = [[NSString alloc] initWithFormat: @"%@/%@2.jpg", [sysPaths objectAtIndex: 0], gem.detailsTitle];
// there is some stuff in here that means that there isn't a one to one relationship between the objects in gem and those in photo
Photo *photo = [[Photo alloc] init];
photo.filePath = filePath;
photo.title = gem.title;
photo.index = [NSNumber numberWithInt:i];
[self.photoAlbum addObject:photo];
[filePath release];
[photo release];
i++;
}
In Instruments, it shows I'm leaking Photo objects and I'm not sure why.
The photoAlbum property is:
@property (nonatomic, retain) NSMutableArray *photoAlbum;
What am I missing?