I have a NSMutableArray instance called entries and I would like to send one of its value (which is a NSDictionary) to a method, but I’m thinking of how to avoid it to leak or properly release it. Here’s what I’m doing right now:
NSDictionary *pdata = [self.entries objectAtIndex:indexPath.row];
[self start_download:pdata];
[pdata release]; // <--> Is it ok to do this ?
Thx for helping,
Stephane
You should absolutely not release
pdata, since you never retained it.-objectAtIndex:returns a non-owned object. If-start_download:needs to refer topdataafter it returns (e.g. if it holds onto it for some asynchronous process) then it should retainpdataitself, and subsequently it should releasepdatawhen it’s done, but that’s orthogonal to the bit of code you pasted.If you haven’t already done so, you should read the Cocoa Memory Management Rules.