English 中文(简体)
Leak是在假释时发生的。
原标题:Leak occur at the time of Parsing

I m actually doing parsing at the start of my program and this is my parser.m class i found "leak" in this class in method "foundCharacters" in line

现有要素 价值 = [[SPStating alloc] initWithString:string];

现有要素 数值为NSMutable 页: 1

NSMutableString *currentElementValue;

Can any one suggest me the way to solve this leak which some times crash my app in the starting...

Thanks In Advance...

事实 方法:-

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
    attributes:(NSDictionary *)attributeDict {
    if([elementName isEqualToString:@"posts"]) {
        appDelegate.newsArray = [[NSMutableArray alloc] init];
    }
    else
    {
        if([elementName isEqualToString:@"page"])
        {

            aNewsInfo = [[NewsInfo alloc] init];
            aNewsInfo.page = [[attributeDict objectForKey:@"id"] integerValue];

        }


        if(![elementName compare:@"smallimage"])
        {
            currentElementValue = [NSMutableString string];

        }
        if(![elementName compare:@"largeimage"])
        {
            currentElementValue = [NSMutableString string];
        }
    }
    NSLog(@"Processing Element :%@",elementName);
}

Leak 发现 特征方法:一行。

现有要素 价值 = [[SPStating alloc] initWithString:string];

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 
    if(!currentElementValue) 
        现有要素 价值 = [[SPStating alloc] initWithString:string];
    else
        [currentElementValue appendString:string];

    NSLog(@"Processing Value: %@", currentElementValue);
}

采用的方法:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if([elementName isEqualToString:@"posts"])
        return;
    if([elementName isEqualToString:@"page"]) {
        [appDelegate.newsArray addObject:aNewsInfo];
        NSLog(@"%d",[appDelegate.newsArray count]);
        NSLog(@"%@",aNewsInfo.title);
        NSLog(@"%@",aNewsInfo.fulltext);
        [aNewsInfo release];
        aNewsInfo = nil;
    }
    else {
        if ([elementName isEqualToString:@"smallimage"])
        {
            NSURL *url = [NSURL URLWithString:currentElementValue];
            NSData *data = [NSData dataWithContentsOfURL:url];
            UIImage *image = [[UIImage alloc] initWithData:data]; 
            [aNewsInfo setSmallImageData:image];

        }
        if(![elementName compare:@"largeimage"])
        {
            NSURL *imageURL = [NSURL URLWithString:currentElementValue];
            NSData *data =  [NSData dataWithContentsOfURL:imageURL];
            UIImage *image = [[UIImage alloc] initWithData:data];
            [aNewsInfo setLargeImageData:image];
            [image release];
        }
        [aNewsInfo setValue:currentElementValue forKey:elementName];
        [currentElementValue release];
        currentElementValue = nil;
    }
}
问题回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签