views:

85

answers:

1

Can anyone tell me what I am doing wrong with the bottom section of code. I was sure it was fine but "Leaks" says it is leaking, which quickly changing it to the top version stops, just not sure as to why?

// Leaks says this is OK
if([elementName isEqualToString:@"rotData-requested"]) {
    int myInt = [[self elementValue] intValue];
    NSNumber *valueAsNumber = [NSNumber numberWithInt:myInt];
    [self setRotData:valueAsNumber];
    return;
}

.

// Leaks says this LEAKS    
if([elementName isEqualToString:@"rotData-requested"]) {
    NSNumber *valueAsNumber = [NSNumber numberWithInt:[[self elementValue] intValue]];
    [self setRotData:valueAsNumber];
    return;
}

any help would be appreciated.

gary

+1  A: 

bug , the memory leak check tools always produce bug

Robin