What exactly happens when these lines of code is run + iPhone -
visitwebsitevc *visitwebsite = [[[visitwebsitevc alloc] initwithnibname:@"visitwebsitevc" bundle:nil] retain]; [self.navigationcontroller pushviewcontroller:visitwebsite animated:yes]; [visitwebsite dealloc];
what happen due [visitwebsite dealloc].
first of should never invoke dealloc method (except [super dealloc] in dealloc).
you code should throw bad_access exception
(retain count) alloc = 1 retain +1 = 2 push +1 = 3 dealloc = 0
but visitwebsitevc instance still in use navigation controller
what should :
visitwebsitevc *visitwebsite = [[visitwebsitevc alloc] initwithnibname:@"visitwebsitevc" bundle:nil]; [self.navigationcontroller pushviewcontroller:visitwebsite animated:yes]; [visitwebsite release];
Comments
Post a Comment