views:

247

answers:

0

Hi all ! need some help

In my app i have a NavigationController, in it i set a UIViewController with the delegates : UITableViewDelegate, UITableViewController and UISearchBarDelegate.

I set my table view using an array, i set an another array to do search.

When a row is selected, i push a viewController, i use my ChangeProductText function to get the text of cell and use it as label in the viewController which is pushed when row is selected.

Basicaly i have a QuestionArray and ReponseArray, i use the QuestionArray to do search, for each object at an index from the question array there is the reponse at the same index. Usually i in the didSelectRow method i set the two label using my function change product text. But this not working in when i implement my SearchBar method as the questionArray change i can load the label in the nextViewController using in the didSelectRow method : [nextController changeProductText:questionArray objectAtIndex:indexPath.row]

i use the same method to set the reponse label, but i can't update my reponseArray accordingly to the question array. I've searched a lot please help

i think i should update my reponseArray in here :

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText

`[questionArray removeAllObjects];// remove all data that belongs to previous search

if([searchText isEqualToString:@""]searchText==nil){

[myTableView reloadData];

return;

}

NSInteger counter = 0;

for(NSString *name in dataSource)

{

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];

NSRange r = [name rangeOfString:searchText];

if(r.location != NSNotFound)

{

if(r.location== 0)//that is we are checking only the start of the names.

{

[arrayQuestion addObject:name]; //i think this here i should update my reponseArray

}

}

counter++;

[pool release];

}

[myTableView reloadData];

} `

Thanks to all