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 7439987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:47:04+00:00 2026-05-29T10:47:04+00:00

I have two UITableViewController classes, MainTableController and SubTableController. From AppDelegate class I am calling

  • 0

I have two UITableViewController classes, MainTableController and SubTableController.

From AppDelegate class I am calling MainTableController class.

At first this class is empty, and there is button named “show list” in this class.
When I click on this button I will go to SubTableController and there I have a list of actions in form of table.
Now if I choose to first cell action then that action name has to come on my first cell of table in MainTableController. But I am not able to print that name in table of MainTableController class.

In SubTableController:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{   
    ActionList * actionListObj = [appDelegate.actionArray objectAtIndex:indexPath.row];  
    self.chooseActions = actionListObj.actionName;
    MainTableController * mainViewController = [[MainTableController alloc] init];      
    [mainViewController getAction:self.chooseActions];
    [self.navigationController dismissModalViewControllerAnimated:YES];
}

In MainTableController:

-(void) viewWillAppear:(BOOL)animated{
    [self reloadData];
}

-(void) reloadData{
    [self.myTableView reloadData];
}

-(void) getAction: (NSString *) actionChoose{        
    self.action = actionChoose;
    [self reloadData];
}       

-(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];
    }
    // Configure the cell...
    cell.textLabel.text = self.action;
    return cell;
}

When I debug, in MainTableController I am getting the action in getAction method but in table cell text string is null.

Can anyone please help me regarding this?Where am I going wrong?

  • 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-05-29T10:47:05+00:00Added an answer on May 29, 2026 at 10:47 am

    You are allocating and initializing a new view controller each time you select a cell in SubTableController.

    MainTableController * mainViewController = [[MainTableController alloc] init];
    

    and of course, it isn’t the one in place in the navigation stack.

    You need to make these two controllers communicate.
    I suggest that the sub view controller define a property on the main one, in order to message it when needed.

    In SubTableController, add a property and synthesize it :

    @property(readwrite, assign) MainViewController *mainViewController;
    // and ...
    @synthesize mainViewController;
    

    Of course when you push the sub view controller, don’t forget to set the property.

    // in main view controller
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // alloc/init the sub VC
        subVCInstance.mainViewController = self;
        [self pushViewController:subVCInstance ......
    

    Now when a row is selected in the sub one, message the main one, without alloc/init a new MainViewController object :

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {   
        ActionList * actionListObj = [appDelegate.actionArray objectAtIndex:indexPath.row];  
        self.chooseActions = actionListObj.actionName;
        //MainTableController * mainViewController = [[MainTableController alloc] init];      
        [self.mainViewController getAction:self.chooseActions];
        [self.navigationController dismissModalViewControllerAnimated:YES];
    }
    

    This should work just fine.

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

Sidebar

Related Questions

I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
I have two classes, and want to include a static instance of one class
I have 2 classes that inherit UITableViewControllers. And this two table views should use
I have a UITableViewController which has two sections. The first section shows a single
I have a navigation controller that works with two UITableViewControllers. The first UITableViewController shows
I have two UITableViewControllers such that when I click next on the first UITableViewController,
I have two NSMutableString objects defined in my viewController's (a subclass of UITableViewController) .h
I have two identical tables and need to copy rows from table to another.
When you have an UIViewController and UITableViewController classes and you wanted to let these
In my 'Sectioned' UITableView I have two sections, the first one for Attributes like

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.