ios - Wrong value in cell after search -
i'm new in objective c, , here problem. have array of 2 values, int & string:
[messier new:1 :@"name 1"], [messier new:2 :@"name 2"]...
i pushed these array in tableview, in tableview have uisearchbar. when tap cell create text button "show"
i need return array int value of selected name(name in cell). in normal state(before searching) button returns me right value, after searching returns wrong. example(look on picture above) andromeda have number 11, butterfly 20, beehive 30, i'm searching beehive(numb 30), after search(beehive first cell) value 11(it's andromeda value), not 30 need.
here serchbar code:
-(void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext { if([searchtext isequaltostring:@""] || searchtext == nil) { searching = no; } else { searching = yes; [searcharray removeallobjects]; searcharray = [[nsmutablearray alloc] init]; searchdictionary = [[nsmutabledictionary alloc] init]; nsarray *sourcearray; nsdictionary *sourcedictionary; sourcearray = [[astrodata sharedastrodata] messierobjectsarray]; sourcedictionary = [[astrodata sharedastrodata] messiernameindexesdictionarry]; for(nsstring *key in [sourcedictionary allkeys]) { nsarray *messier = [sourcedictionary objectforkey:key]; for(messier *mess in messier) { nsrange result = [mess.name rangeofstring:searchtext options:(nscaseinsensitivesearch | nsdiacriticinsensitivesearch)]; if(result.location != nsnotfound) { nsmutablearray *existingarray; if((existingarray = [searchdictionary objectforkey:key])) { [existingarray addobject:mess]; } else { nsmutablearray *temparray = [nsmutablearray array]; [searchdictionary setobject:temparray forkey:key]; [temparray addobject:mess]; } } } } for(id key in sourcearray) { if([searchdictionary objectforkey:key]) [searcharray addobject:key]; } } [table reloadallcomponents]; }
maybe have problem table view? thank all.
p.s. sorry english)
problem in text button "show", need add in method
if(search) .... else ... code
Comments
Post a Comment