Internal compiler error: Bus error

2019-03-01 21:54发布

问题:

Im trying to make a UITableView with a View with Details but I get two errors. After the following code I got two times the same errors: 'Internal compiler error: Bus error' and I have no idea why? Can someone help me? You can find a image of the code under here.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSInteger row = [indexPath row];
if (self.verwaltungDetailViewController == nil){
    verwaltungDetailViewController *aVerwaltungDetail = [[verwaltungDetailViewController alloc] initWithNibName:@"VerwaltungDetailView" bundle:nil];
    self.verwaltungDetailViewController = aVerwaltungDetail;
    [aVerwaltungDetail release];

}
verwaltungDetailViewController.title =  [NSString stringWithFormat:@"%@", [verwaltungsArray objectAtIndex:row]];



NatersAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.VerwaltungNavController pushViewController:verwaltungDetailViewController animated:YES];

}

Thanks a lot in advance for your help!

回答1:

It looks to me like you've got a class somewhere called VerwaltungDetailViewController (note the uppercase 'V') and you are mixing it up with an instance variable & property called verwaltungDetailViewController (note the lowercase 'v'). In the first line of the if block, you are attempting to create an instance of the latter, when you should be attempting to create an instance of the former. Your code should look something like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSInteger row = [indexPath row];
if (self.verwaltungDetailViewController == nil){
    VerwaltungDetailViewController *aVerwaltungDetail = [[verwaltungDetailViewController alloc] initWithNibName:@"VerwaltungDetailView" bundle:nil];
    self.verwaltungDetailViewController = aVerwaltungDetail;
    [aVerwaltungDetail release];

}
verwaltungDetailViewController.title =  [NSString stringWithFormat:@"%@", [verwaltungsArray objectAtIndex:row]];



NatersAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.verwaltungNavController pushViewController:verwaltungDetailViewController animated:YES];

Edit: You also make the mistake in the last line of code, except in reverse.