0

I am trying to track down a zombie, I have run the application with NSZombies enabled. A message is being send to a deallocated object in BookEventViewController (code below).

the crash happens when moving from through the UITabBar buttons. BookEventViewController is not on the uiTabBar it is navigated to from EventsTableViewController that is on the TabBarController.

the crash only happens when you have navigated from EventsTableViewController to BookEventViewController and then press the tabButtons.

I am struggling to see exactly what I am doing wrong. I have looked at the out put from the instruments and the zombie is caused by

[UiNavigationController viewWillApear] 

it is at this point I am stuck any ideas greatly appreciated

here is my class

@implementation BookEventViewController
@synthesize _Image,dateLabel,titleLabel,details,dresscode,Type,capacity,rsvp,runtime,location,price,bookButton,alert,starttime;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.hidesBottomBarWhenPushed=NO;
        self.navigationController.delegate=self;
        self.tabBarController.delegate=self;

    }
    return self;
}

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
   // NSLog(@"nav called");
    self.tabBarController.tabBar.hidden=NO; //hides tabbar of parent view
    self.hidesBottomBarWhenPushed=NO;
}
-(void)dealloc
{
    self.navigationController.delegate=nil;
    self.tabBarController.delegate=nil;
}

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden=YES;
    [self loadDataFromDb];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
     _Image.image=[UIImage imageNamed:@"drinksimg"];
    _Image.clipsToBounds=YES;
    self.navigationController.delegate=self;
    self.tabBarController.tabBar.hidden=YES;
    UISwipeGestureRecognizer *vertical=[[UISwipeGestureRecognizer alloc]
                                        initWithTarget:self
                                        action:@selector(back)];
    vertical.direction=UISwipeGestureRecognizerDirectionRight;
    [self.view addGestureRecognizer:vertical];
   [Functions setFontFamily:@"Neutra Display" forView:self.view andSubView:YES];
    regist=0;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

and here is the out put from the interments

#Event Type ∆ RefCt RefCt   Timestamp   Responsible Library Responsible Caller
162 Zombie      -1  00:20.374.056   UIKit   -[UINavigationController viewWillAppear:]
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mark Gilchrist
  • 1,972
  • 3
  • 24
  • 44
  • When you get the crash there should be a line somewhere (console, crash log…) that says what message is being sent to the deallocated object. Also…perhaps unrelated but the docs for `viewWillAppear` say "If you override this method, you must call super at some point in your implementation." – Phillip Mills Apr 15 '14 at 12:19
  • i think if you are using the tabbar then you need not to navigate via navigation controller. – Mohit Manhas Apr 15 '14 at 12:20
  • I have added [super viewWillApear:animated]; to my code but this is still causing a crash – Mark Gilchrist Apr 15 '14 at 14:42
  • Is this ARC or manual memory management? – Walt Sellers Apr 15 '14 at 16:17
  • Do you get a console message about the message sent to a deallocated object? If so, can you paste the actual message into your question? – Phillip Mills Apr 16 '14 at 12:43

1 Answers1

0

I think I have found the problem. I have added the lines

-(void)viewWillDisapear:(bool)animate
 {
     self.navigationController.delegate=nil;
     self.tabBarController.delegate=nil;
     [super viewWillDisapear:animate];
 }

,removed the dealloc method and I am now not getting the crash. thanks for you help

Mark Gilchrist
  • 1,972
  • 3
  • 24
  • 44