Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jeremyapp

macrumors newbie
Original poster
Apr 30, 2008
27
0
Hey everyone,

I have a bit of code that is leaking and I can't seem to figure out why.

I have an XML Parser, and here's one of the snippets from its didEndElement method:

Code:
else if([elementName isEqualToString:@"link"])
	{
		NSString *link = [currentAttribute stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
		[tempElement setLink:link];
	}

CurrentAttribute is an NSMutableString that I clear out every time I encounter a new object. tempElement is a custom object that I use to store parsed values.

I use the stringByReplacingOccurencesOfString method to remove spaces from links that I pull from an RSS feed.

Doing this should return an autoreleased object, right?

It seems this bit of code leaks though. Any thoughts?
 
Remember that the leaks tool doesn't tell you where leaks occur. It tells you where an object that is leaked was created. So those lines you show are where the object was created, not where it leaked.

Also, remember that because of common use of collections classes you can have the leaks tool show you a large number of leaks that really are a single leak. If you leak an array that holds a hundred other objects all the objects will show as leaked. If you fix the leak of the array then all the other objects won't leak.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.