Reputation: 737
i have in my parser :
+(NSArray *)parseMethode:(NSData *)xmlData {
...
return [myNSArray autorelease];
}
and in an other controller i have done this :
@synthesize anOtherNSMutableArray;
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSData *responseData = [self.currentRequest responseData];
self.anOtherNSArray = [MyClassParsers parseMethode:reponseData];
...
}
and when i lunch instruments it detect me a leak in the line :
self.anOtherNSArray = [MyClassParsers parseMethode:reponseData];
is there a leak in my code ??
thanks for your answers
Upvotes: 0
Views: 87
Reputation: 939
I guess that you have defined this kind of property for anOtherNSArray :
@property (...,retain) NSArray *anOtherNSArray;
the retain property means that using the accessor will retain the value automatically ! using the accessor :
self.anOtherNSArray = something;
will do the same than not using the accessor but retaining the value :
anOtherNSArray = [someting retain];
You should either :
The last option is the easier and safest one (doing "self.anOtherNSArray = nil ;" as stated by Jhaliya will release the instance and set it to nil) !
Reading that may help you understanding a little bit more what are properties : http://cocoacast.com/?q=node/103
Upvotes: 0
Reputation: 31722
Try with below
self.anOtherNSArray = nil ;
self.anOtherNSArray = [MyClassParsers parseMethode:reponseData];
Upvotes: 1
Reputation: 15147
Just try this
NSData *responseData = [self.currentRequest responseData] autorelease];
Upvotes: 0