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 synth开发者_高级运维esize 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
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)
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.
精彩评论