4

My app crashes on launch with the following error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableViewChannels.

This is a project that I've inherited and re-worked significantly. I thought initially that tableViewChannels was an old array, but I've searched the whole project in XCode and it doesn't appear anywhere.

I went into the storyboard with my favorite text editor to look at the raw XML, and did indeed find two instances of "tableViewChannels" which appear to have been old IBOutlets (they no longer actually appear in the visual storyboard). I deleted both, saved, cleaned the build folder, restarted XCode, and still crash with exactly the same error. I'm perplexed as to where this code is still lurking in the project. I appreciate any help. Thanks!

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
Reid
  • 1,109
  • 1
  • 12
  • 27
  • 1
    possible duplicate of [setValue:forUndefinedKey: this class is not key value coding-compliant for the key](http://stackoverflow.com/questions/13793162/setvalueforundefinedkey-this-class-is-not-key-value-coding-compliant-for-the-k) – Gabriele Petronella Oct 04 '13 at 17:22
  • Should add I also broke all segues and connections, and re-made them. No dice. – Reid Oct 04 '13 at 17:29
  • 1
    `tableViewChannels` still has a pending outlet somewhere. Dig deeper. – Gabriele Petronella Oct 04 '13 at 17:32
  • Thanks, but if I've searched for it in the raw XML and it's not there, where should I look? – Reid Oct 04 '13 at 17:35
  • Well, a little update...I opened it as source code within XCode and the outlets are still there! Did it override what I did in my text editor? Now I'm really confused...but I'll try deleting them there and see if it's a fix. – Reid Oct 04 '13 at 17:41

4 Answers4

6

i am not entirely sure but this issue might be cause in your storyboard/xib there must be an IBOutlet which was earlier connected variable but later this variable was removed.. please go through each xib and see if u have this.. else a better way is.. type "tableViewChannels" in xcode.. select the word any try to refractor it.. this will list all the files its going to refactor.. including xibs. :) this way u can be sure if tableViewChannels is there in any of ur xibs

dRAGONAIR
  • 1,181
  • 6
  • 8
  • Thanks but I believe I've done that...tableViewChannels doesn't appear anywhere in the storyboard, neither visually nor when I search the raw XML. Even an unused outlet would still have to appear in the XML, right? – Reid Oct 04 '13 at 17:32
  • 1
    just try refractoring... because i had a similar issue and i found the IBOutlet by refactoring only... :) – dRAGONAIR Oct 04 '13 at 17:44
  • 1
    Well, you were correct. I have no idea why, but when I opened the storyboard as source in XCode (which I just discovered is possible) the outlet was still there, even though I had deleted it and saved in my text editor...who knows. Anyway, it's fixed. Thanks!! – Reid Oct 04 '13 at 17:45
1

You can see if Xcode has any metadata files that still include "tableViewChannels" by searching the project directory in Terminal:

cd [path to project]
grep -r --include='*' tableViewChannels .
paulrehkugler
  • 3,241
  • 24
  • 45
1

Easy to solve in three steps:

  1. Secondary click in the storyboard file, in my case "Storyboard.storyboard"
    Click on "Open as" and then on "Source Code"

  2. In the keyboard press "Command" + "F", to find the key, in this case "tableViewChannels"

  3. Once found, select the line and erase it.

As it was said before, it is a problem with a connection in the storyboard, attempting to connect a property that was deleted or doesn't exist. Almost always, the property existed and was erased without knowing the crash it would make to your app using storyboard.

Dirty-flow
  • 2,306
  • 11
  • 30
  • 49
JuanM.
  • 434
  • 1
  • 8
  • 19
0

Had the same issue, there were no outlets to delete, it was just an XCode problem and got it resolved by deleting Derived Data and cleaning the project.

aleksie3006
  • 149
  • 2
  • 5