Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>indexPath</code> you passing to your <code>detailController</code> in <code>favoritesView</code> isn't the same like the one in <code>mainView</code>. So you have to do some magic to parse the filtered <code>indexPath</code> back to the original unfiltered list.</p> <pre><code>- (NSArray*)readPlist // still filtered list { NSMutableArray *returnArr = [[self readFullPlist] mutableCopy]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"isFav == YES"]; for (NSDictionary *sect in returnArr) { NSArray *arr = [sect objectForKey:@"Rows"]; [sect setValue:[arr filteredArrayUsingPredicate:predicate] forKey:@"Rows"]; } return returnArr; } - (NSArray*)readFullPlist // split that method to get the unfiltered list separately { NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *plistPath = [[documentPaths lastObject] stringByAppendingPathComponent:@"tipsList.plist"]; NSFileManager *fMgr = [NSFileManager defaultManager]; if (![fMgr fileExistsAtPath:plistPath]) { NSString *bundlePlistPath = [[NSBundle mainBundle] pathForResource:@"tipsList" ofType:@"plist"]; [self writePlist:[NSArray arrayWithContentsOfFile:bundlePlistPath]]; } return [NSArray arrayWithContentsOfFile:plistPath]; } - (NSIndexPath*)realIndexPathForIndex:(NSIndexPath*)idxPath { NSArray *fullList = [self readFullPlist]; NSArray *subArr = [[fullList objectAtIndex:idxPath.section] objectForKey:@"Rows"]; int row = idxPath.row; int newRow = 0; for (NSDictionary *dic in subArr) { if ([[dic valueForKey:@"isFav"] boolValue]) { if (row == 0) { return [NSIndexPath indexPathForRow:newRow inSection:idxPath.section]; } row--; } newRow++; } return idxPath; } </code></pre> <p>Then in <code>didSelectRowAtIndexPath:</code> you pass this converted <code>indexPath</code> instead of the old one:</p> <pre><code>//detail.indexPath = indexPath; detail.indexPath = [self realIndexPathForIndex:indexPath]; </code></pre> <p>Something I want to mention. Instead of using the <code>indexPath</code> you should use an unique identifier if possible. This would make things (like this one) much easier because you only pass that <code>id</code> to the next controller.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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