I have a nib ViewController that I'm loading into a scroll view container using this code:
let friendsFeedVC = UIViewController(nibName: "FriendsFeedViewController", bundle: nil)
In my storyboard for the FriendsFeedViewController.xib file, I added a navigation bar and dragged an IBOutlet into the FriendsFeedViewController.swift file to hook up the outlet like I normally do.
When I run the app and the Nib is loaded in the scroll view, it causes a crash saying:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navBar.' *** First throw call stack: (0x1847b5900 0x183e23f80 0x1847b55c0 0x1850aff74 0x189817f1c 0x189972cb8 0x1846df3ac 0x1899716a0 0x18981b33c 0x1895e4250 0x1894a7d6c 0x1894a7cc4 0x100096b4c 0x100097a40 0x1894a80c0 0x1894a7cc4 0x1894aeab4 0x1894abfa0 0x189521cd0 0x1000fb904 0x1000fbae8 0x18951d704 0x18974c130 0x1897504b8 0x18974d5c0 0x185d6b790 0x185d6bb10 0x18476cefc 0x18476c990 0x18476a690 0x184699680 0x189516580 0x189510d90 0x1000fbfec 0x18423a8b8) libc++abi.dylib: terminating with uncaught exception of type NSException
Here are screenshots showing that the IBOutlet is set up. Is it not being instantiated? What's the solution? I have cleaned the project and I don't have any random outlets floating around from previous use. Also, the Nib loads fine if I remove the IBOutlet, so the problem only comes once I hook it up I guess.