objective c - UitableView Search Text Sigbart Error - ios -
i've implemented search bar (and display controller) in uitableview using code outlined below. when type in search text box following sigabrt error:
terminating app due uncaught exception 'nsunknownkeyexception', reason: '[ valueforundefinedkey:]: class not key value coding-compliant key name.'
i've re-reviewed tutorial i've been following , quadruple checked code cant find cause of error, can help?
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (tableview == self.searchdisplaycontroller.searchresultstableview) { return [self.searchresults count]; } else { return _restaurantsincity.count; } } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"restaurantcell"; uitableviewcell *cell = [_tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier]; cell.accessorytype = uitableviewcellaccessorydisclosureindicator; } restarauntentity *currentrestaurant = nil; if (tableview == self.searchdisplaycontroller.searchresultstableview) { currentrestaurant = [[self.searchresults objectatindex:indexpath.row]]; } else { currentrestaurant = [self.restaurantsincity objectatindex:indexpath.row]; } nsstring *decodedtext1 = [currentrestaurant.title stringbyreplacingoccurrencesofstring:@"’" withstring:@"'"]; nsstring *decodedtext = [decodedtext1 stringbyreplacingoccurrencesofstring:@"&" withstring:@"&"]; cell.textlabel.text = decodedtext; cell.textlabel.font = [uifont fontwithname:@"avenir" size:16.0f]; cell.textlabel.textcolor=[uicolor blackcolor]; cell.detailtextlabel.text = currentrestaurant.city; cell.detailtextlabel.font = [uifont fontwithname:@"avenir" size:12.0f]; cell.detailtextlabel.textcolor=[uicolor darkgraycolor]; return cell; } - (void)filtercontentforsearchtext:(nsstring*)searchtext scope:(nsstring*)scope { nspredicate *resultpredicate = [nspredicate predicatewithformat:@"name contains[cd] %@", searchtext]; searchresults = [_restaurantsincity filteredarrayusingpredicate:resultpredicate]; } -(bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring { [self filtercontentforsearchtext:searchstring scope:[[self.searchdisplaycontroller.searchbar scopebuttontitles] objectatindex:[self.searchdisplaycontroller.searchbar selectedscopebuttonindex]]]; return yes; }
try
it happens if have created outlet or action on button does't exists more. check actions , outlets. go storyboard , right click on yellow sign of viewcontroller , delete actions , outlets yellow sign.
hope helps.
libc++abi.dylib: terminating uncaught exception of type nsexception (lldb)
try answer hope helps.
Comments
Post a Comment