Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:28:56+00:00 2026-06-06T13:28:56+00:00

I have 2 tableViews, the first one is the Main table and the second

  • 0

I have 2 tableViews, the first one is the Main table and the second one is the Favorites table.

Everything is handled with a plist.

From the detailView of the first table, in the upper-right corner, I created a button that writes to the plist the value YES or NO for that cell, so that that specific cell will be shown in the table Favorites.

Now the problem is that:

  • I select a row from the first table, the main one. detailView appears and i tap on the UIBarButton making that detail a Favorite (and so a star image appears into the button as an image to let user know that the cell is a favorite). OK.
  • I go to the second table, the favorites one, choosing the cell previously favorited and i see that the star is empty, then the bool value is set to NO (and it’s supposed to be set to YES due i Favorited it moments ago).

I noticed that if i add to favorites the first item of the firstTable, then the other cells in the second view are shown correctly, even after i favorited them all in the first view.

A bit tricky, i know, but it’s happening.

Any idea why?

The method i’m using for reading the plist is the following:

- (NSArray*)readPlist 
{  
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
    NSString *plistPath = [[documentPaths lastObject] stringByAppendingPathComponent:@"tipsList.plist"]; 
    NSFileManager *fMgr = [NSFileManager defaultManager]; 
    if (![fMgr fileExistsAtPath:plistPath]) { 
        plistPath = [[NSBundle mainBundle] pathForResource:@"list" ofType:@"plist"]; 

    } 

    NSMutableArray *returnArr = [NSMutableArray arrayWithContentsOfFile:plistPath]; 
    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;
    [self.tableView reloadData];
}

cellForRow:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }


    NSArray *rows;
    if (tableView == self.searchDisplayController.searchResultsTableView) {
        rows = filteredList;
    } else {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"isFav == YES"]; 

        NSDictionary *section = [localSortedTips objectAtIndex:indexPath.section];
        rows = [section objectForKey:@"Rows"];
        [rows filteredArrayUsingPredicate:predicate];

    }

    cell.textLabel.text = [[rows objectAtIndex:indexPath.row] objectForKey:@"name"];        
    return cell;
}

And the didSelectRow:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{   NSDictionary *section = [localList objectAtIndex:indexPath.section];

    NSArray *rows = [section objectForKey:@"Rows"];
    NSDictionary *item = [rows objectAtIndex:indexPath.row];

        detailViewController *detail = [[detailViewController alloc] initWithNibName:@"detailViewController" bundle:nil];
        detail.indexPath = indexPath;
        detail.imageString = [item valueForKey:@"image"]; 
        detail.nameString = [item valueForKey:@"name"];
        detail.title = [item valueForKey:@"name"];
        detail.descriptionString = [item valueForKey:@"description"];

        [self.navigationController pushViewController:detail animated:YES];
        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        [detail release];
    }

}

EDIT WITH PICS

Okay so. I select the first row in the first section of the mainTable, and the detailView appears:

Then i favorite it through that little star, setting its value to YES in the plist

Then I go into the Favorites table, clicking on the previously favorited element and it appears like so

OK. This works. but only for this one!

In fact, if i try to select i.e. a row in the middle of the mainTable, and try to favoriting it, the detailView looks like

But then, selecting it in the Favorites table looks like so, empty star, while it should be favorited and then filled. If i try to favorite it through the star, and coming back to the Favorites table, the previous row in the mainTable appears, even if it’s not favorited.

I noticed that if i keep the first element, it works fine, but if i remove it, it doesn’t work ANYTHING anymore. :\

Any help highly appreciated,stuck from 2 weeks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:28:57+00:00Added an answer on June 6, 2026 at 1:28 pm

    The indexPath you passing to your detailController in favoritesView isn’t the same like the one in mainView. So you have to do some magic to parse the filtered indexPath back to the original unfiltered list.

    - (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;
    }
    

    Then in didSelectRowAtIndexPath: you pass this converted indexPath instead of the old one:

    //detail.indexPath = indexPath;
    detail.indexPath = [self realIndexPathForIndex:indexPath];
    

    Something I want to mention. Instead of using the indexPath you should use an unique identifier if possible. This would make things (like this one) much easier because you only pass that id to the next controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table views, when user clicks one cell of the first, second
I have two views, first one is with calendar and the second one is
So I have two tableViews, one is shown first in a popover, then when
I have a grouped table with 3 categories and one header above the first
I have a 2 tabs application. In the first one, I'm creating objects of
In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have two views: the first one is a UITableView in plain style (created
I have custom backgrounds (one for first rows, other for middle rows and other
I am having problem in populating data from a table in one screen to
I have a drill down tableview that is using sqlite. The first one is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.