Note that there are some explanatory texts on larger screens.

plurals
  1. POSearching a custom tableviewCell
    primarykey
    data
    text
    <p>I want to do a search in a tableview. But in this table view I work with a custom tableview Cell. So for the data part. I select in a view a categorie. Then in the next view I get all the products within this categorie. I followed this <a href="http://www.iphonesdkarticles.com/2009/01/uitableview-searching-table-view.html" rel="nofollow">tutorial</a> an implemented all the methods. </p> <p>This is my function for getting the products.</p> <pre><code>-(void) fillArrayProducts:(NSString *)cat{ NSMutableString *postString = [NSMutableString stringWithString:kGETProducts]; [postString appendString:[NSString stringWithFormat:@"?%@=%@",@"Pro_cat",cat]]; [postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSMutableURLRequest *request= [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]]; [request setHTTPMethod:@"POST"]; postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:postString]]; NSError *error; json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;error]; arrayProducts = [[NSMutableArray alloc] init]; copyArrayProducts = [[NSMutableArray alloc] init]; arrayProductNaam = [[NSMutableArray alloc] init]; for (int i=0; i&lt;[json count]; i++) { arrayProduct = [[NSMutableArray alloc] init]; [arrayProduct addObject:[json objectAtIndex:i]]; [arrayProducts addObject:arrayProduct]; [arrayProductNaam addObject:[[[arrayProducts valueForKey:@"Pro_naam"] objectAtIndex:i]objectAtIndex:0]]; [copyArrayProducts addObject:arrayProduct]; } NSDictionary *productsDict = [NSDictionary dictionaryWithObject:arrayProductNaam forKey:@"Products"]; NSLog(@"%@",arrayProductNaam); } </code></pre> <p>No what i'm doing. I have an array 'arrayProducts' in this array I put arrays from 'arrayProduct'. In arrayProduct you can find Pro_id,Pro_naam,Pro_prijs. But I only want to search on Pro_naam. So I fill also an array (arrayProductNaam) with only the products names.</p> <p>So here is the part were I do my search.</p> <pre><code>- (void) searchTableView { NSString *searchText = searchbar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary *dictionary in arrayProductNaam) { NSArray *array = [dictionary objectForKey:@"Pro_naam"]; [searchArray addObjectsFromArray:array]; } for (NSString *sTemp in searchArray) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch]; if (titleResultsRange.length &gt; 0) [copyArrayProducts addObject:sTemp]; } } </code></pre> <p>I think that it's here were I getting this error.</p> <blockquote> <p>2012-02-02 13:22:40.958 MamzelBestelling2[23727:f803] -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x6c34780 2012-02-02 13:22:40.959 MamzelBestelling2[23727:f803] <em>*</em> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x6c34780'</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload