0

I'm seeing other questions posted re iOS 6 so I hope its now kosher to ask them here ...

I am testing a published app built using Xcode GM 4.5. I am getting a crash when loading a table view controller on a device running GM iOS 6 firmware. The crash doesn't happen when building to devices running iOS 5.1 or 4.3.5. I am infering (perhaps incorrectly) from the error included below that there must be a problem with the way the table view's outlet is connected but as it works in 5.1 and 4.3.5 and the code is identical as to what is happening in iOS 6 I am not clear as to what is going wrong.

I've deleted previous versions of the app from the device, reset it and cleaned the project but that does not help.

I've looked at release notes but am not seeing anything that points to what needs to be done in iOS 6.

The error is:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "XViewController" nib but didn't get a UITableView.'

Thanks for any pointers on what I need to do to fix this.

-- Additional info:

(Note: XViewController is actually LogViewController in the app.)

In the class interface file I have the outlet declared as:

@property (strong, nonatomic) IBOutlet UITableView *logTableView;

In the xib here is the connections inspector for File's Owner:

enter image description here

larick
  • 259
  • 5
  • 12
  • The exception seems pretty clear and explicit to me – AliSoftware Sep 13 '12 at 22:28
  • 1
    @AliSoftware In that case you should post an answer. – Darren Sep 14 '12 at 01:20
  • I agree @Darren. Perhaps my question is "dumb" or the solution is obvious, but isn't the purpose of SO to assist others who are sincerely trying to figure things out as opposed to being down voted for asking questions they have researched and tried to solve on their own but are stuck on? This has not been my experience in the past on SO. I may have found a clue to an answer to this issue at http://stackoverflow.com/questions/11137669/xcode-4-5-corrupting-xibs, but the solutions therein are not working for me to solve this problem. – larick Sep 14 '12 at 05:31

1 Answers1

2

The exception [UITableViewController loadView] loaded the "XViewController" nib but didn't get a UITableView. means that your "XViewController.xib" file contains an UITableViewController class (probably its File's Owner?) whose view IBOutlet is binded to something other than an UITableView.

UITableViewController instances needs their view outlet to be an UITableView (or one of its custom subclass if you created any), and NOT to be any other kind of UIView (even if that UIView contain some UITableView in its subclass or whatever) like in your capture.

AliSoftware
  • 32,623
  • 6
  • 82
  • 77
  • thanks for the details. I've added some details to my question to show the connections in the xib and the outlet in the class interface. I believe this is set up correctly, but perhaps you see something awry. As mentioned exception only occurring when the project is built using Xcode 4.5 GM to iOS 6 device and not to earlier devices. I am thinking now that there may be something in the xib which is broken/incompatible in the exception scenario and so I will now recreate the xib under Xcode 4.5 and see if that resolves the issue. Curiously other table views in app don't crash. – larick Sep 14 '12 at 16:58
  • In your capture you added it appears to me that **you have exactly the problem I described above**. **You `view` outlet is bound to an `UIView` instance, and not to an `UITableView`**. Change your `view` outlet to bind it to the `UITableView` the `logTableView` outlet is bound to in your capture. Your `logTableView` IBOutlet will no longer be necessary as you will access your tableView directly thru `self.tableView` which for an `UITableViewController` simply return the same as `(UITableView*)self.view`. – AliSoftware Sep 14 '12 at 17:03
  • Note that if you really can't point your `UIViewController`'s `view` outlet to your tableView directly (because you need an intermediate view that holds your `UITableView` but also other `subviews` for example), you will need to make your custom `UIViewController` a subclass of `UIViewController` instead of being a subclass of `UITableViewController`, as (as explains multiple times here) `UITableViewController` instances have the constraint to force you to have the `UITableView` they manage as their `view` directly (see the documentation) – AliSoftware Sep 14 '12 at 17:06
  • OK. I see now, changed the connection and got rid of the exception. I'm still puzzled though as to how it worked on lower version devices ... Thanks for your help @AliSoftware. – larick Sep 14 '12 at 17:08
  • 1
    Yup it shouldn't have been working on previous versions neither, don't understand why you didn't get the exception before. Maybe building cache problems? (an old version of the XIB compiled before had the `UITableView` directly bound to `view` outlet, and when you modified it in the previous version to add your `logTableView` the change wasn't taken into account, that happens occasionally if you rename the XIB and don't clean your project before rebuilding or don't remove the DerivedData folder) – AliSoftware Sep 14 '12 at 17:12