UIAlertView - showing memory leak

I am relatively new to iPhone Development, so this may be my mistake, but this is contrary to what I saw. :)

I think I'm creating a UIAlertView that lives in this very vacuum of the if statement.

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

if(!data)
{
    // Add an alert
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                    message:@"Unable to contact server"
                                                   delegate:nil
                                          cancelButtonTitle:@"Ok"
                                          otherButtonTitles:nil];
    NSLog(@"retain count before show: %i", alert.retainCount);
    [alert show];
    NSLog(@"retain count before release: %i", alert.retainCount);
    [alert release];
    NSLog(@"retain count after release: %i", alert.retainCount);
    return nil;
}

However, console magazines disorient me.

retain count before show: 1
retain count before release: 6
retain count after release: 5

I also tried adding:

alert = nil;

after graduation. This makes the hold counter 0, but I still see the leak. And if that helps, the leak The responsible frame is UIKeyboardInputManagerClassForInputMode. I also use OS 4 Beta 3.

So, does anyone have any idea how the local UIAlertView counter will increment itself by 5 when -show is called?

Thank you for your help!

+5
source share
3 answers

, , [alert show] . , , [alert show] - - , . , . , , .

UIAlertView, didPresentAlertView, , , , "" . , . dealloc, .

+6

, . : ..: , . , , , .

+3

I assume this is due to the sdk beta. There are a lot of bugs / errors in the beta version. I would suggest checking it out with 3.1.3 or 3.2 sdk.

0
source

All Articles