Reputation: 171
I want to make view controller at run time with the nib name like this, But this is being crashed.
Error
[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageViewApp.
let vc = UIViewController(nibName: nibName, bundle: nil)
When I try with the static values like this
let vc = MyViewController(nibName: "MyViewController", bundle: nil)
, it is working.
This is the IBOutlet in MyViewController
I googled it but haven't found enough solution please let me know the solution.
Upvotes: 0
Views: 62
Reputation: 313
Remove imageViewApp property IBOutlet from that view controller and give that ImageView a tag and access it with the tag.
Upvotes: 1
Reputation: 40221
You're initializing a UIViewController and UIViewController has no imageViewApp property. You need to initialize your own subclass where you define that property, as you do in your second example.
Try something like this:
let vc = MyViewController(nibName: nibName, bundle: nil)
If your nib file has the same name as your class, you don't have to specify it:
let vc = MyViewController(nibName: nil, bundle: nil)
Upvotes: 2