Pregunta

I have been trying to debug this error, and I can't find the issue. From what I have researched, I think that this is telling me that I am trying to release an object that has already been real eased, although I am not sure. I have a object that acts as the delegate for a NSXMLParser object, and I have a property of type NSMutableString that I use to hold the characters of each element. Here is my code:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    self.stringBuffer = [NSMutableString string];

    if ([elementName isEqualToString:@"item"])
        self.parsingPodcast = YES;


    if (attributeDict)
        self.currentAttributesDict = attributeDict;
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if (string) [self.stringBuffer appendString:string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if (self.parsingPodcast)
    {
        if ([elementName isEqualToString:@"title"])
        {
            self.currentPodcastObject.title = self.stringBuffer;
        }
        else if ([elementName isEqualToString:@"pubDate"])
        {
            self.currentPodcastObject.publishDate = self.stringBuffer;
        }
        else if ([elementName isEqualToString:@"summary"])
        {
            self.currentPodcastObject.summary = self.stringBuffer;
        }
        else if ([elementName isEqualToString:@"imageurl"])
        {
            self.currentPodcastObject.imgURL = self.stringBuffer;
        }
        else if ([elementName isEqualToString:@"enclosure"])
        {
            self.currentPodcastObject.audioURL = [self.currentAttributesDict objectForKey:@"url"];
            self.currentPodcastObject.audioType = [self.currentAttributesDict objectForKey:@"type"];
        }
        else if ([elementName isEqualToString:@"itunes:duration"])
        {
            self.currentPodcastObject.duration = self.stringBuffer;
        }
        else if ([elementName isEqualToString:@"item"])
        {
            parserCompletionBlock(self.currentPodcastObject);
        }
    }
}

I've enabled zombies in the scheme, and used the zombie tool to try and find any over released object, but I haven't been able to find anything. Here is the output on the console

:malloc: *** error for object 0x10e7531f0: double free
*** set a breakpoint in malloc_error_break to debug

I have added the malloc_error_break breakpoint

The breakpoint stops on the setter method for the self.stringBuffer property. Can anyone help me out? I must be missing something. Thanks in advance for your help!

¿Fue útil?

Solución

[NSMutableString string] is autorelease. you should retain when assigning it on self.stringBuffer.

self.stringBuffer = [NSMutableString string] retain]

Otros consejos

I actually got this error because the memory in my phone was almost full. Once i cleared some apps in my phone, the error went away. Not sure if this is useful, but it definitely helped me.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top