Search code examples
iphoneuitableviewexc-bad-accessnszombie

Cannot Identify Zombie Object in iPhone Application


I am a noob making a simple signature capture application for the iPhone.

The application is suppost let the user navigate to a table view populated with deliveries. Then, they would click on the delivery they are currently delivering.

I am coming across an EXC_BAD_ACCESS error when I try to load the table view, so I ran the Zombie Diagnostic Instrument to see if i could find the problem. I got a Zombie error, however non of the "Responsible Caller"'s are in reference to any code I wrote.

So the basic flow of my app thus far is I have a View that has 3 buttons on it, one of them leads to a table view and then it crashes if you use it.

this is the code for the view switch:

-(IBAction) deliveriesButtonClicked:(id)sender {
    if (self.deliveriesViewer == nil) {
        DeliveriesViewerController *aOptionController = [[DeliveriesViewerController alloc] initWithNibName: @"DeliveriesViewerController" bundle: nil];
        self.deliveriesViewer = aOptionController;
        [aOptionController release];
    }

    [self.mainNavigationController.view removeFromSuperview];
    [self.view insertSubview:self.deliveriesViewer.view atIndex:0];

}

This is the code for the deliveries class that it is switching to

Header:

#import < UIKit/UIKit.h >

@interface DeliveriesViewerController : UITableViewController <UITableViewDelegate> {
    IBOutlet UITableView *myTable;
}

@property (nonatomic, retain) UITableView *myTable;

@end

Implementation:

#import "DeliveriesViewerController.h"
#import "AppDelegate.h"

@implementation DeliveriesViewerController

@synthesize myTable;

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}    

- (void)viewDidUnload {

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    return appDelegate.invoices.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *MyIdentifier = @"MyIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    cell.text = [appDelegate.invoices objectAtIndex:indexPath.row];
    return cell;
}

@end

If anyone could possibly help me find this problem it would be greatly appreciated.


Solution

  • I figured out the problem.

    The problem was that i had the wrong datasource and delegates for the table view. By default was set to the tableview itself not to the file owner.

    Thank you for showing intrest in my problem.