Friday, November 18, 2016

[IOS Swift] - using UIImagePickerController

Hello everyone,

   This presentation covers the UIImagePickerController and all the features that we can take on Images for IOS coding. Please, watch this video(below), if you want the code, please send me an e-mail.

Link:
https://youtu.be/Zre0K2Bd5Vk

Or Video:



Happy Coding,
Thiago Leoncio.

Tuesday, November 15, 2016

[IOS Swift] NSUnknownKeyException, reason: [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key string


Hello everyone,

I just would like to write about these kind of inexplicable exceptions that are very common when we merge code in IOS:

Example1:
2016-11-15 04:46:28.168 Paging_Swift[15793:407011] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7ffdb9512510> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnClickMe.'
*** First throw call stack:

Example2:
2016-11-15 05:16:58.366 Paging_Swift[16020:422108] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fea38c2ee50> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageView.'


In order to fix this such inexplicable exceptions, you must understand - they are often a result of an unclean xib file. Open the xib in xcode, select File's Owner and click on the "Connection Inspector" (upper right arrow), to see all outlets at once. Look for !s which indicates a missing outlet.

So, if you go to your storyboard and the ViewController outlets that you are working on, you will probably find some of them with the '!' signal. Like this:




In this particular case, the specific a controller scene came from a different project, it was renamed as brand new viewController. In this case and for other cases that comes with this exception you can go in two different directions. Here they are:


  •  Rebuild the outlets.
  • Just change the class Name in the reference of this new project. Like this: to ViewControllerImage



After change it, you are going to see all the outlets working properly as below.


I hope it helps and happy coding,
Thiago Leoncio.