11

This is the error message I get: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel.' The below explains how it differs from the other questions posted. Since I am actually following the instructions from the link provided.

I have linked the Xib as follows: The ViewController I would like to use is MapViewController. The Xib is MarkerInfoView The file owner is MapViewController and it's also where I have created the outlets.

enter image description here

user2867432
  • 382
  • 4
  • 14
  • 1
    Possible duplicate of [What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"](https://stackoverflow.com/questions/3088059/what-does-this-mean-nsunknownkeyexception-reason-this-class-is-not-key-v) – CodeNinja Oct 06 '17 at 23:04
  • it's different in the sense that I use the answers provided there. Also this is for XCode 9 and swift not objective C and the older version of Xcode shown there. – user2867432 Oct 06 '17 at 23:41
  • It's difficult to tell much from what you posted, but in my experience this error happens when your outlets are mismatched. Try reviewing each one to make sure they point to a valid outlet and make sure there are no extra outlets, left by maybe changing names or erasing code and not the connection – CodeNinja Oct 06 '17 at 23:48
  • happy to add details. But the screen shots were meant to show that the outlets were properly set up, as well as the FileOwner. – user2867432 Oct 06 '17 at 23:53
  • Actually I just realized, the error specifically says there's a problem with your nameLabel outlet. Maybe try unconnecting and reconnecting that outlet? – CodeNinja Oct 06 '17 at 23:57
  • Thank you, just tried it again. I deleted the connection and the variable in the code, then recreated it. Same error message. – user2867432 Oct 07 '17 at 00:02
  • Just opened as source code as well and I don't see any problem with potential multiple connections. – user2867432 Oct 07 '17 at 00:25
  • Remove the old outlet from code and from inspector and try making a new one. – Chaudhry Talha Oct 20 '17 at 07:10
  • Thx Chaudhry but already tried that... – user2867432 Oct 20 '17 at 12:50
  • Maybe you need to have in your Xib file a ViewController (I'm assuming you only have the View). – Adi Oct 20 '17 at 20:59
  • Thx Adi. Already present too. – user2867432 Oct 20 '17 at 21:27

3 Answers3

0

i think that this happens becouse when you register your xib with a fileowner it maybe recreated and the outlets are disconeccted automaticlly. i don't use that way of registring nibs

Enea Dume
  • 3,014
  • 3
  • 21
  • 36
  • Thx but I tried adding the outlets again per my discussion with CodeNinja so that doesn’t happen. What’s the other approach you are referring to? – user2867432 Oct 25 '17 at 06:35
  • remove MarkerInfoView from file's owner and add it at View, which is down first responder. that's how i use them, becouse i used to have the same problem – Enea Dume Oct 25 '17 at 06:59
  • Thanks enea but I need the xib as it is because it's used as a marker on a map. So it wouldn't work in this case. – user2867432 Oct 25 '17 at 15:57
  • Hi Enea, was revisiting this. What did you mean by "add it at View". What is "it"? thanks – user2867432 Nov 21 '17 at 18:42
0

For using xibs initialize with MapInfo(nibName: "XibName", bundle: nil)

0

Other possible thing is that your outlets actually connected to mapinfoview, not controller. Delete them and recreate onto your viewcontroller

  • Hello, Please see the following : "Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel." – user2867432 Nov 10 '17 at 01:18