Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

this class is not key value coding-compliant for the key name. UISearchBar and DisplayController

I'm making an app that uses a UITableViewController and I'm trying to add a UISearchBarWithDisplayController. (I'm using this tutorial: http://www.appcoda.com/search-bar-tutorial-ios7/). I followed all the steps, but when I press a letter on the keyboard in the Search view the app crashes and I get this error:

2014-05-28 19:11:03.850 Williams[1353:60b] *** Terminating app due to
uncaught exception     'NSUnknownKeyException', reason:
'[<__NSCFConstantString 0x100219d80> valueForUndefinedKey:]: this
class is not key value coding-compliant for the key name.'
*** First throw call stack: (0x186b8a950 0x1930901fc 0x186b8a5d4 0x1876db618 0x187624bdc 0x18766d8e8 0x18766d3d0 0x18766c1d4
0x18766c150 0x18766bf28 0x100038904 0x100038af8 0x189d6c558
0x189b890e8 0x189b8905c 0x189b72538 0x189d6c264 0x189b93a64
0x189d27a7c 0x189d26dfc 0x189d26ae4 0x187634a20 0x189b97e58
0x189d269ac 0x189b7d2f0 0x18770c5cc 0x186b4b044 0x186b4a3a0
0x186b48638 0x186a896d0 0x18c76dc0c 0x189bbafdc 0x10003970c
0x193683aa0) libc++abi.dylib: terminating with uncaught exception of
type NSException

It crashes when I press a letter on the keyboard and gets stuck like this:

Crash

What's also weird is that if I crash it in the iOS Simulator, it gives me a different crash report:

2014-05-28 19:25:33.490 Williams[6847:60b] *** Terminating app due to
uncaught exception 'NSUnknownKeyException', reason:
'[<__NSCFConstantString 0x1002091f8> valueForUndefinedKey:]: this
class is not key value coding-compliant for the key name.'
*** First throw call stack: (   0   CoreFoundation                      0x0000000102a6d495 __exceptionPreprocess + 165  1   libobjc.A.dylib   
0x00000001027cc99e objc_exception_throw + 43    2   CoreFoundation      
0x0000000102af1919 -[NSException raise] + 9     3   Foundation           
0x00000001024313c6 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:]
+ 226   4   Foundation                          0x00000001023ae155 -[NSObject(NSKeyValueCoding) valueForKey:] + 251     5   Foundation                          0x0000000102383922 -[NSFunctionExpression
expressionValueWithObject:context:] + 1003  6   Foundation            
0x00000001023fbbd0 -[NSComparisonPredicate
evaluateWithObject:substitutionVariables:] + 236    7   Foundation      
0x00000001023fbae2 -[NSPredicate evaluateWithObject:] + 19  8  
Foundation                          0x00000001023fba7d
_filterObjectsUsingPredicate + 353  9   Foundation                          0x00000001023fb89a -[NSArray(NSPredicateSupport)
filteredArrayUsingPredicate:] + 286     10  Williams                     
0x000000010000ede2 -[StaffTVC filterContentForSearchText:scope:] + 162
  11  Williams                            0x000000010000ef8c -[StaffTVC
searchDisplayController:shouldReloadTableForSearchString:] + 316    12 
UIKit                               0x00000001016c286e
-[UISearchDisplayController searchBar:textDidChange:] + 126     13  UIKit                               0x000000010137af1e -[UIApplication sendAction:to:from:forEvent:] + 104
  14  UIKit                               0x000000010137aeb4
-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17  15  UIKit                               0x0000000101457880 -[UIControl
_sendActionsForEvents:withEvent:] + 203     16  UIKit                               0x00000001019bfe84 -[UITextField fieldEditorDidChange:] + 198   17 
UIKit                               0x00000001019cbb97
-[UITextInputController _sendDelegateChangeNotificationsForText:selection:] + 102   18  UIKit                               0x00000001019cd670 -[UITextInputController _insertText:fromKeyboard:]
+ 651   19  UIKit                               0x00000001019cdddc -[UITextInputController insertText:] + 301   20  UIKit                               0x0000000101523e00 -[UIKeyboardImpl insertText:] + 82   21  Foundation 
0x0000000102442d34 -[__NSOperationInternal _start:] + 623   22  UIKit  
0x0000000101522827 -[UIKeyboardImpl performOperations:] + 148   23 
UIKit                               0x0000000101520e17
__73-[UIKeyboardImpl replyHandlerForHandleKeyboardInputWithExecutionContext:]_block_invoke_2
+ 40    24  UIKit                               0x00000001019e35c6 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 329   25  UIKit                               0x000000010152f4ff -[UIKeyboardImpl handleKeyEvent:] + 220  26  UIKit 
0x0000000101375f8e _UIApplicationHandleEventQueue + 2572    27 
CoreFoundation                      0x00000001029fcd21
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17     28  CoreFoundation                      0x00000001029fc6b9
__CFRunLoopDoSources0 + 441     29  CoreFoundation                      0x0000000102a1846f __CFRunLoopRun + 767     30  CoreFoundation           
0x0000000102a17d83 CFRunLoopRunSpecific + 467   31  GraphicsServices   
0x000000010374ff04 GSEventRunModal + 161    32  UIKit                   
0x0000000101379e33 UIApplicationMain + 1010     33  Williams             
0x0000000100010743 main + 115   34  libdyld.dylib                      
0x00000001070575fd start + 1    35  ???                                
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException
like image 924
ZenthyxProgramming Avatar asked Nov 11 '22 07:11

ZenthyxProgramming


1 Answers

Try this one:

NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"self contains[c] %@", searchText];

Need to use "self", not "name"

like image 101
Vitaliy Avatar answered Jan 04 '23 03:01

Vitaliy