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

  • SEARCH
  • Home
  • 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 8416167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:40:05+00:00 2026-06-10T01:40:05+00:00

I have a table view with a list of items from the AppDelegate. The

  • 0

I have a table view with a list of items from the AppDelegate. The table view allows the user to select the item they want and there is a checkmark next to the item after the selection has been made. Next the user can go back to the previous screen and this selection updates a string value which is displayed to the user. This value is also stored in the AppDelegate. Everything works well but I would like this value to be automatically selected if the user chooses to GO BACK into the screen where the user can change their selection.

Here is the cellFroRowAtIndexPath function in my SetSizeViewController.m

I am having trouble getting the value stored in appDelegate.selectedSize to be selected. This value, for example, could be something like ‘Meter’.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
 self.checkedIndexPath = indexPath;

[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];

[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];

[tableView deselectRowAtIndexPath:indexPath animated:YES];

UITableViewCell *result = nil;

static NSString *CellIdentifier = @"CellIdentifier";

result = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (result == nil){
    result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

TabAndSplitAppAppDelegate *appDelegate = (TabAndSplitAppAppDelegate *)[[UIApplication sharedApplication] delegate];
SetSize *setSize = (SetSize *)[appDelegate.setSizes objectAtIndex:indexPath.row];

appDelegate.selectedSize = setSize.name;

appDelegate.selectedSizeCheckedIndexValue = (NSInteger *)indexPath.row;

[tableView reloadData];
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

TabAndSplitAppAppDelegate *appDelegate = (TabAndSplitAppAppDelegate *)[[UIApplication sharedApplication] delegate];

if(appDelegate.selectedSize.length > 0)
{
    if ((int)indexPath.row == (int)appDelegate.selectedSizeCheckedIndexValue) {

        [cell setSelected:YES animated:YES];
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    } else {
        [cell setSelected:NO];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
}
}
  • 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-10T01:40:07+00:00Added an answer on June 10, 2026 at 1:40 am

    you should avoid calling didSelectRowAtIndexPath: yourself. anyway, you should try calling [result setSelected:YES animated:YES].

    also, how are you checking if the this cell is the one to be selected? correct me if im wrong but it seems to me that with this if(appDelegate.selectedSize) { ..., every cell is going to be true for the selection code.

    EDIT:

    remove [result setSelected:YES animated:YES] from cellForRowAtIndexPath and add the following:

    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if (indexPath.row == mySelectedRow) { //mySelectedRow is the index value you stored previously.
    
            cell.selected = YES; //or [cell setSelected:YES animated:YES] if you want it to be animated.
        }
    }
    

    EDIT 2:

    first adjust your if function in willDisplayCell: just in case to this:

    if ((int)indexPath.row == (int)appDelegate.selectedSizeCheckedIndexValue) {
    
        [cell setSelected:YES animated:YES]; //or animated:NO depends on what you need.
        [self performSelector:@selector(unselectCellAtIndexPath:) withObject:indexPath afterDelay:1.0]; //add a delay to the deselection. you can change the delay time to whatever suits you.
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    
    }
    else {
    
        [cell setSelected:NO];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    -(void)unselectCellAtIndexPath:(NSIndexPath *)indexPath {
    
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
    

    then inside your didSelectRowAtIndexPath:, after you select your cell, call [tableView reloadData]

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

Sidebar

Related Questions

I have created a TableView(Grouped Table View). And I can list the items in
I have an app that allows the user to move from a list of
I have a table view with a list of items. When I click on
i have to show 3 columns in List view. I tried having table inside
I have table View with grouped style with three sections. Get information from dictionary
I have a List<> of items which I want to display in a 3
I have a table with a list of contract line items in the form
I have an app which uses a table view to display a list of
I have this basic shopping list app where in the first view there are
I have a following scenario. A list of table rows. ... <tr><td><a href=# class=item

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.