Charlotte1993
Charlotte1993

Reputation: 609

Container view controller app crash NSInternalInconsistencyException in Swift?

I have a UIViewcontroller with a container view inside. In the storyboard, the container view is connected with the UIViewcontroller through an Embed Segue. I do not need to pass data from the ParentView Controller to the Child View Controller. The ChildViewController has a CustomViewController class, but since I don't need to pass any data between the 2 view controllers, the only reference between them is the embed segue in the Storyboard.

Every time I open the parent view controller, the app crashes, with the following error:

*** Terminating app due to uncaught exception 'NSInternalIncosistencyException', reason: 'NSDictionaryOfVariableBindings failed bacause either one of the values is nil, or there's something wrong with the way the macro is being invoked. Cannot assign value nil for key "childView". Keys:( childView )'

Any idea what is causing this error and how to fix this? I'm working with Xcode 8.1 and Swift 3

Upvotes: 1

Views: 1241

Answers (2)

neoscribe
neoscribe

Reputation: 2421

I had this issue when I tried to embed a sub-classed UITableViewController in a container view from Interface Builder. The problem was that layout was trying to find the view associated with the controller, but it had not been initialized.

The fix for me was this:

- (void)loadView {
   [super loadView];//<-- don't forget to call this!!!
}

Upvotes: 4

Mangesh Kondaskar
Mangesh Kondaskar

Reputation: 214

Looks like the childView Instance is nil.

Upvotes: -1

Related Questions