Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nekbeth

macrumors regular
Original poster
Feb 20, 2011
101
0
Vatican City
Hi, I'm looking for a way to search my detailviews, so when the user starts typing inside the bar, he can then select the row and push it's particular detail view.

how can you achieve this?

Thank you
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You don't search views. You search in the model layer that provides the data to the views. In respect of how to do this no-one can answer: it is 100% dependent on how you have written the code for the model layer and have chosen to represent the data.
 

Nekbeth

macrumors regular
Original poster
Feb 20, 2011
101
0
Vatican City
You don't search views. You search in the model layer that provides the data to the views. In respect of how to do this no-one can answer: it is 100% dependent on how you have written the code for the model layer and have chosen to represent the data.


I see robbie, what if my model is plist and I represent my data by using string numbers (integers), then in my code I push them using a switch statement. This is all working fine with me so far, but if I want to insert a Search Bar, I can find the text for the detailview but because the searchBar show only row # 1, it will always push the same controller.


What can I do to fix that?

( I'm learning Core Data right now and it seems to address a lot of problems like mine regarding queries (retrieving data) , fetching, search, etc.)
 

Sykte

macrumors regular
Aug 26, 2010
223
0
I see robbie, what if my model is plist and I represent my data by using string numbers (integers), then in my code I push them using a switch statement. This is all working fine with me so far, but if I want to insert a Search Bar, I can find the text for the detailview but because the searchBar show only row # 1, it will always push the same controller.


What can I do to fix that?

( I'm learning Core Data right now and it seems to address a lot of problems like mine regarding queries (retrieving data) , fetching, search, etc.)

If it's in an Array\Dict you could use NSPredicate.
 

Nekbeth

macrumors regular
Original poster
Feb 20, 2011
101
0
Vatican City
For Sykte or Robbie (or anyone else reading this thread).


Can I use this condition statement in DidSelectRowAtIndexPath ??

In this case, it's used to send a message to searchText:

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


What I'm trying to figure out is if there is a way to push the controllers (detailviews) by their name (strings) instead of it's number (integers)?

Thank you
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
That is because it not complete, I only pasted the part I was interested on. The complete code is on the link that Sykte provided.

That line is not syntactically valid. It basically reads as:

Code:
if (boolValue1 boolValue2) {

This is not valid: there must be a binary operator between boolValue1 and boolValue2.
 

Nekbeth

macrumors regular
Original poster
Feb 20, 2011
101
0
Vatican City
Yes, it seems it has some syntax problems. A user correct it here:

Code:
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
[tableData 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.
{
[tableData addObject:name];
}
}
counter++;
[pool release];
}
[myTableView reloadData];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.