Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

this class is not key value coding-compliant for the key authView [duplicate]

When i run my app on simulator it runs well, when i try with device doesn't work and i get these errors:

NOTE: i didn't find any kind of class authView in my code

2011-02-24 12:04:14.472 TestP[473:307] *** Terminating app due to uncaught exception     'NSUnknownKeyException', reason: '[<TestP 0x19d2b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key authView.'
*** Call stack at first throw:
(
0   CoreFoundation                      0x33ac0987 __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x3347b49d objc_exception_throw + 24
2   CoreFoundation                      0x33ac0705 -[NSException dealloc] + 0
3   Foundation                          0x3367db4f -[NSObject(NSKeyValueCoding)    setValue:forUndefinedKey:] + 182
4   Foundation                          0x3367d03b _NSSetUsingKeyValueSetter + 90
5   Foundation                          0x3367eda3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 194
6   Foundation                          0x33630b17 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 130
7   UIKit                               0x3224c60f -[UIRuntimeOutletConnection connect] + 66
8   CoreFoundation                      0x33a63fc7 -[NSObject(NSObject) performSelector:] + 18
9   CoreFoundation                      0x33a6cd51 -[NSArray makeObjectsPerformSelector:] + 388
10  UIKit                               0x3224b577 -[UINib instantiateWithOwner:options:] + 586
11  UIKit                               0x3224cb39 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
12  UIKit                               0x3209e871 -[UIApplication _loadMainNibFile] + 96
13  UIKit                               0x3209a1fd -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 180
14  UIKit                               0x3206648b -[UIApplication handleEvent:withNewEvent:] + 1114
15  UIKit                               0x32065ec9 -[UIApplication sendEvent:] + 44
16  UIKit                               0x32065907 _UIApplicationHandleEvent + 5090
17  GraphicsServices                    0x33b0ef03 PurpleEventCallback + 666
18  CoreFoundation                      0x33a556ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
19  CoreFoundation                      0x33a556c3 __CFRunLoopDoSource1 + 166
20  CoreFoundation                      0x33a47f7d __CFRunLoopRun + 520
21  CoreFoundation                      0x33a47c87 CFRunLoopRunSpecific + 230
22  CoreFoundation                      0x33a47b8f CFRunLoopRunInMode + 58
23  UIKit                               0x32099309 -[UIApplication _run] + 380
24  UIKit                               0x32096e93 UIApplicationMain + 670
25  TestP                               0x00002213 main + 98
26  TestP                               0x000021ac start + 40
)
terminate called after throwing an instance of 'NSException'
like image 670
Robert Bed Avatar asked Feb 24 '11 19:02

Robert Bed


People also ask

How do I fix this class is not key value coding compliant for the key?

You can fix the error by breaking the connection that is causing the problem. Simply click the X to delete the outlet. Then you can go back to the View Controller and simply recreate the connection. Just hold the control key and drag and drop the mouse pointer to the outlet you want to connect.

What is key value coding?

Key-value coding is a mechanism enabled by the NSKeyValueCoding informal protocol that objects adopt to provide indirect access to their properties. When an object is key-value coding compliant, its properties are addressable via string parameters through a concise, uniform messaging interface.


4 Answers

@Dave DeLong pointed out right.

Workaround

  • Find when the exception thrown, which viewController is being loaded.
  • Then check the nib file of the viewController, there must be an IBOutlet attached in xib but might be missed in the viewController.h file or might be some control which was attached is missing in xib file.

Why running in Simulator? Sometimes it ends in messing up.

Just do the steps

  1. Build -> Clean
  2. Build -> Clean All Targets

Now it runs the real code, may be issue got resolve on device also or may be it start throwing exception on simulator also in case if there is really an issue. (I already have mentioned workaround)

like image 43
Waqas Raja Avatar answered Nov 15 '22 11:11

Waqas Raja


You've probably got your File's Owner stuff messed up in your xibs. This exception is getting thrown during nib unarchiving (as evidenced by +[UINib...] in the backtrace). It's attempting to hook up your IBOutlets that you defined.

One of your views is set up to be the authView of the the File's Owner. However, when it's time to unarchive the nib, the owner doesn't have an authView property, so the unarchiving is failing.

like image 139
Dave DeLong Avatar answered Nov 15 '22 13:11

Dave DeLong


This is how I solved this problem. I went into my 'Story Board' file and selected the view that was causing the problems. I then clicked on the Connections Inspector tab and you will see connection(s) with exclamation points to the right instead of solid circles. Remove these and make adjustments if necessary. Save>Run your app and should work. Hope this helps :)

like image 32
daveomcd Avatar answered Nov 15 '22 11:11

daveomcd


I think that one possible cause for raising that exception is when you have changed the name of some IBOutlet variable after the storyboard connections are already done. Thus the UI element in the storyboard is still referencing to the old variable name. I solved this for me by checking the XML representation of the storyboard (Right click on your .storyboard file and open it as Source Code) and deleting the old (unneeded) IBOutlet variable name.

For example let say you have one UITextField on the storyboard and have the corresponding property for it:

@property (retain, nonatomic) IBOutlet UItextField *myTextField;

You connect the UI element in the storyboard to that property and then you decide to rename somehow the variable. Now if you right click on your UITextField in the storyboard, you will notice that there exists two referencing outlets - the old one and the new one. You can delete the old one by clicking 'x' sign in the Connections Inspector or by editing the XML variant of the storyboard file.

like image 44
oistanchev Avatar answered Nov 15 '22 11:11

oistanchev