danskcollignon
danskcollignon

Reputation: 62

Leak in iPhone App

my app is nearly finished but a leak has appeared.

After having spent an hour trying to find out how to solve this link, I can't find a solution. I'm sure one of you will help me out :)

Here is the screenshot from XCode

Thanks for your help!

Upvotes: 0

Views: 84

Answers (3)

TomSwift
TomSwift

Reputation: 39512

Add an autorelease to the sortdescriptor that you inline alloc/init and add to that array.

Upvotes: 1

Matthias Bauch
Matthias Bauch

Reputation: 90117

You are allocating a NSSortDescriptor without releasing it. The analyzer is pointing you at the line already.

To resolve that issue you have to replace

NSArray *sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"distanceFromHome" ascending:YES]];

with

NSArray *sortDescriptors = [NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"distanceFromHome" ascending:YES] autorelease]];

Upvotes: 4

hol
hol

Reputation: 8423

I am not sure but can you assign the NSSortDescriptor a variable and release it after you used it? For me the leak has to do with the NSSortDescriptor. But that you can find out very fast.

Upvotes: 0

Related Questions