Note that there are some explanatory texts on larger screens.

plurals
  1. POindexPath of filtered tableView
    primarykey
    data
    text
    <p>In my project I use core data with magical record.</p> <p>My search bar works perfectly, but after a search If I tap on the first row of my tableview I get the detail view of the table not filtered:</p> <p>so if I have 3 object named A, B, C and I search C, in my table I see only C but if i tap I get the detail view of A.</p> <p>So I'm try to write a method to get the correct indexPath:</p> <pre><code> -(NSIndexPath*)giveMeSearchedObject:(UISearchBar*)searchBar showInRow: (int) row { NSPredicate *predicate = [NSPredicate predicateWithFormat:@"nome CONTAINS [cd] %@", searchBar]; NSArray *arra = [Ricetta MR_findAllSortedBy:@"nome" ascending:YES withPredicate:predicate]; Ricetta*ctn = arra[row]; NSIndexPath* correctPath =arra[row]; return correctPath; } </code></pre> <p>but when I call this method in the prepareForSegue to set the indexPath I can't figure out what write after "showInRow:":</p> <pre><code>if (searching == YES) { NSIndexPath *indexPath = [[NSIndexPath alloc]init]; indexPath = [[DataManager sharedClass]giveMeSearchedObject:self.mySearchBar.text showInRow:???; DetailViewController*dvc = segue.destinationViewController; dvc.indice =indexPath.row; </code></pre> <p>So, maybe the method isn't correct.</p> <p>somebody could help me?</p> <p><strong>UPDATE</strong></p> <pre><code>@interface @property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController; @end @implementation @synthesize fetchedResultsController; - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showDetail"]) { if (searching == YES) { UITableViewCell*cell = (UITableViewCell*)sender; NSIndexPath*indexPath = [self.tableView indexPathForCell:cell]; Ricetta*ricetta = [self.fetchedResultsController objectAtIndexPath:indexPath]; DetailViewController*dvc = segue.destinationViewController; dvc.indice =indexPath.row; </code></pre>
    singulars
    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.
 

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