ios - xCode search bar crash when I'm trying to query data with parse -


so here's code

- (void)viewdidload {     [super viewdidload];      _queriedresults = [[nsmutablearray alloc]init] }  -(void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext{     [_queriedresults addobjectsfromarray:[self searchbarquery:[searchtext lowercasestring]]]; } -(nsarray*)searchbarquery:(nsstring*)searcheduser{     nsarray * users;     pfquery *query = [pfuser query];     [query wherekey:@"username" equalto:[searcheduser lowercasestring]];     users = [query findobjects];     return users; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell" forindexpath:indexpath];     cell.textlabel.text = [_queriedresults[indexpath.row]username];     return cell; } 

so main functions i'm using in view controller class. i've done debugging , queriedresults succesfully name of user searching, tableview:cellforrowatindexpath makes app crash when queriedresults has values inside array. i've set cell identifier , code working fine when test normal temp array.. don't know why it's crashing when query parse database.

this message when app crashes.

nsinternalinconsistencyexception', reason: 'unable dequeue cell identifier cell - must register nib or class identifier or connect prototype cell in storyboard'

i'm getting error -

assertion failure in -[uisearchresultstableview dequeuereusablecellwithidentifier:forindexpath:],

but have cell registered thought.. why works other arrays when i'm testing. don't know what's wrong code.

it sounds using uisearchdisplaycontroller or uisearchcontroller. in both cases, tend reuse cellforrow method new table view maintained controller. 1 solution register cells on new table view controller, solution ask original table view dequeue cell new table view.

for more information older uisearchdisplaycontroller, see http://useyourloaf.com/blog/2012/09/06/search-bar-table-view-storyboard.html

for more information newer uisearchcontroller, see http://useyourloaf.com/blog/2015/02/16/updating-to-the-ios-8-search-controller.html


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -