tags:

views:

36

answers:

1
VisitWebsiteVC *visitWebSite = [[[VisitWebsiteVC alloc] initWithNibName:@"VisitWebsiteVC" bundle:nil] retain];
            [self.navigationController pushViewController:visitWebSite animated:YES];
            [visitWebSite dealloc];

What will happen due to [visitWebSite dealloc].

+4  A: 

Hi,

First of all you should NEVER invoke the dealloc method (except [super dealloc] in dealloc).

You code should throw a BAD_ACCESS exception

(Retain count) Alloc = 1 Retain +1 = 2 Push +1 = 3 Dealloc = 0

But you VisitWebsiteVC instance is still in use by the navigation controller

What you should do is :

VisitWebsiteVC *visitWebSite = [[VisitWebsiteVC alloc] initWithNibName:@"VisitWebsiteVC" bundle:nil];
            [self.navigationController pushViewController:visitWebSite animated:YES];
            [visitWebSite release];
F.Santoni