user317474
user317474

Reputation:

iPhone: App crashes when I click on a cell in table view

Compiling my application works—everything is fine. The only errors I get are by deprecated functions (setText).

The only problem is now, is that when I tap on a cell in my table, the app crashes, even though it's meant to push to the next view in the stack.

Any solutions are appreciated, if you need any code, just ask.

Also, how can I only make sure that one cell goes to only one view? For example:

When I tap on CSS, it takes me to a new table with different levels of CSS. WHen I tap on an item in that new view, it comes up with an article on what I just selected.

Regards,
Jack

Here's my code at the didSelectRowAtIndexPath method:

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

    if(indexPath.row==0){

    NextViewController *nextController = [[NextViewController alloc]
                                          initWithNibName:@"NextView" bundle:nil];
    [self.navigationController pushViewController:nextController
                                         animated:YES];
    [nextController changeItemTable:[arryClientSide
                                     objectAtIndex:indexPath.row]];
}
}
@end

(as requested in the comments).

Upvotes: 0

Views: 1664

Answers (6)

Francescu
Francescu

Reputation: 17054

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: -[UIViewController _loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet was not set.'

  1. Open NextView with Interface Builder
  2. Set Class value at : "NextViewController" to your File's Owner set files owner class
  3. Connect the View outlet (Ctrl click and drag - a blue line should appear - from the File Owner to the UIView and select "view" in options) alt text

Upvotes: 1

Nicolas Manzini
Nicolas Manzini

Reputation: 8546

Don't use IB. Instead, make alloc init with nothing, then in load view:

self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];

Upvotes: 0

AKG
AKG

Reputation: 408

When we create new UIViewControllerSubClass with xib-interface, xib file is created as sourcecode.xib (can be seen in get info of that xib file): Change sourcecode.xib to "file.xib" and see the magic :)

Upvotes: 1

Rigo Vides
Rigo Vides

Reputation: 1364

release that NextViewController you alloc!

[nextController release];

It's leaking.

Upvotes: 0

Vladimir
Vladimir

Reputation: 170839

Error description from comments:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet was not set.'

If your view controller is loaded from nib file and its view is not set exception then exception is thrown. So when you create your view in IB you must connect view outlet to your view controller object (likely - file owner in IB).

Edit: So basically in IB in your nib file you need to do the following:
1. set file owner's type to NextViewController
2. connect NextViewController's view outlet to a View object

Upvotes: 0

MohammedYakub M.
MohammedYakub M.

Reputation: 2941

you need to update your code like this :

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

    if(indexPath.row==0){

    NextViewController *nextController = [[NextViewController alloc]
                                          initWithNibName:@"NextView" bundle:nil];
    [nextController changeItemTable:[arryClientSide
                                     objectAtIndex:indexPath.row]];
    [self.navigationController pushViewController:nextController
                                         animated:YES];
    }
else{   }
}

try using this code...

Upvotes: 0

Related Questions