2

I have never had this problem before or heard of it happening. I am using a Master-Detail Application (splitview) for the ipad. I have a dynamic tableview for my MVC and am trying to transition each cell to a custom view controller.

Currently I only have two items in my table. When the program boots I can select either of them and it will transition to the correct view controller without any problems. But most of the time when I click on something a second time the program crashes. Sometimes it takes four or five clicks but it always eventually crashes.

Here is the code snippet:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *segueName = [self.tableObjects objectAtIndex:indexPath.row];
    [self performSegueWithIdentifier:segueName sender:self];
}

tableObjects is an NSArray that I use to create the table items. If I throw a print statement in before the segue call it does print the correct segue name.

The error is always being thrown on the actual performSegueWithIdentifier call. I checked it with the debugger. The exception I keep getting is: EXC_BAD_ACCESS.

Again both of the segues work initially so I do not think it is a problem with this. Does this method sometimes get called randomly? Is there a way to double check that the method call is safe? Do I need to override performSegueWithIdentifier and do something there?

I attempted to put it into a try catch:

@try {
    [self performSegueWithIdentifier:segueName sender:self];
}
@catch (NSException *exception) {
    NSLog(@"%@", exception);
}
@finally {
    NSLog(@"finally");
}

and it still pointed to the method call inside of the @try. It does not seem to be throwing the error like an exception?

Firo
  • 15,448
  • 3
  • 54
  • 74
  • Do you have more details on the crash? What is printing in the log? Do you have exception breakpoints turned on? – Dan F Jun 25 '12 at 16:23
  • I'd attempt to get more information by putting that line inside a @try/@catch and printing the exception's `callStackSymbols` if the EXC_BAD_ACCESS is all Xcode is giving you. – Phillip Mills Jun 25 '12 at 16:25
  • @Dan Yes I had exception breakpoints turned on. I turned them off and the exact same thing happens. It shows the break at the method call. In both cases it did not print anything in the log. – Firo Jun 25 '12 at 16:33
  • @Joel when you hit that exception, is there anything indicating what the bad access is coming from? Are you accessing something out of bounds on `self.tableObjects`? Did `self.tableObjects` get released somehow? – Dan F Jun 25 '12 at 16:35
  • @DanF The table is fine (at least I think) I can run a for-loop right before the method call and print out the whole table fine (Which at this point is only two items). I can also print out the actual segue name before too. I decided to make segueName a constant (i.e. @"name"). The same things happens. It can access the right segue and view for about two clicks then it crashes again. – Firo Jun 25 '12 at 16:46
  • Alright I am not sure what happened but I just started a new project and everything started to work. Thanks guys. – Firo Jun 26 '12 at 15:39

1 Answers1

3

FYI, I was running into this exact same issue, and I found the answer on another SO thread: iOS - UISplitViewController with storyboard - multiple master views and multiple detail views

Basically, the uisplitviewcontroller delegate needed to be set again when making the segue. Hope this helps someone in the future.

Community
  • 1
  • 1
dreadpirateryan
  • 545
  • 1
  • 7
  • 16