UPDATE : Answer
I posted my answer below which solved this problem for me. Reason for the issue is entirely different to the post that has been suggested.
Original Question:
I am trying to load a UIView from a xib file which is defined as a ViewController.
if let overlayView = (Bundle.main.loadNibNamed("CalendarViewController", owner: self, options: nil)?.first as? JTAppleCalendarView) {
self.navigationController?.view.addSubview(overlayView)
}
However, every time I run the project, I get a unknown key exception.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyApp.ViewController 0x7feac8607cc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key calendarView.'
I have one view in the xib file which I am connecting to its owner (viewcontroller) through a IBOutlet. This key is given as the one that is causing the error. However, when I checked the UIView's referencing outlets, they are in good standing.
I tried removing the reference and re-adding it and also trying to load the xib by specifying the owner to the xib's view controller. Still no luck.
Update: References
Also the connections portion of the xib's xml:
<connections>
<outlet property="calendarView" destination="dqi-m5-FXD" id="mAV-5Y-SXl"/>
</connections>
Related code: