1

I have a leak in the following code:

-(id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        self.Tag = [aDecoder decodeObjectForKey:KEY_TAG];
        self.ParentTag = [aDecoder decodeObjectForKey:KEY_PARENT_TAG];
        self.Order = [aDecoder decodeObjectForKey:KEY_ORDER];
        self.OrderFavorite = [aDecoder decodeObjectForKey:KEY_ORDER_FAVORITE];
        self.isFavorite = [aDecoder decodeObjectForKey:KEY_IS_FAVORITE];
        self.isPurchased = [aDecoder decodeObjectForKey:KEY_IS_PURCHASED];

        self.Titel = [aDecoder decodeObjectForKey:KEY_TITEL];
    }
    return self;
}

The leak appears in instruments on the device in that line:

self.Titel = [aDecoder decodeObjectForKey:KEY_TITEL];

KEY_TITEL is:

#define KEY_TITEL @"Titel"

and self.Titel is:

@property (nonatomic, retain) NSString *Titel;

it is synthesize and it is released in dealloc.

I don't have any idea where the leak is come from. Can you help me out please...

thank you xnz

2 Answers 2

3

You're mis-interpreting what Instruments is telling you.

It is not telling you where you leaked an object.

It is telling you where you created an object that was eventually leaked.

Reanalyze the data from Instruments accordingly. (You're likely missing a [Titel release] call in your -dealloc method)

Sign up to request clarification or add additional context in comments.

Comments

0

Do have you assign a value to Titel before initWithCoder execution ? Maybe in super class ? The leak does not seem to be linked to the initWithCoder execution, but to a previous assignment.

1 Comment

If I don't find the archived object, I assign it from a Dictionary. But if I do so then initWithCoder is not called. Superclass is NSObject, so I don't assign it there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.