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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:57:38+00:00 2026-06-15T20:57:38+00:00

I have a table view on my master view, and a textField on my

  • 0

I have a table view on my master view, and a textField on my detail view. The app is simple. Add a table view cell with some info. Then if you press the cell, it pushes the detail view and shows the cell’s title/text in the text field. In the master view, im using an NSFetchedResultsController. And in the second view, im trying to load the data, but for some reason i am not using my own indexPath variable correctly, because every cell that gets pressed shows the first cells text on the detail view. Code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Set up the cell...
[self configureCell:cell atIndexPath:indexPath];
self.path = indexPath;
    //I have tried this as well.
    //self.path = [NSIndexPath indexPathForRow:indexPath.row inSection:0];
return cell;
}

Detail View:

-(void)viewWillAppear:(BOOL)animated
{
if (self.context == nil)

{

    self.context = [(FBCDAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];

}

NSFetchRequest *request = [[NSFetchRequest alloc]init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"FailedBankInfo" inManagedObjectContext:self.context];

[request setEntity:entity];

NSError *error;

NSMutableArray *array = [[self.context executeFetchRequest:request error:&error] mutableCopy];

[self setTableArray:array];

FailedBankInfo *infoData = [self.tableArray objectAtIndex:self.root.path.row];

NSString *string = [NSString stringWithFormat:@"%@", infoData.name];

self.nameField.text = string;

string = [NSString stringWithFormat:@"%@", infoData.city];

self.cityField.text = string;

string = [NSString stringWithFormat:@"%@", infoData.state];

self.stateField.text = string;

[super viewWillAppear:YES];

}
  • 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-15T20:57:40+00:00Added an answer on June 15, 2026 at 8:57 pm

    Why not just pass the index path into the detail view controller in the

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    

    method, with a custom initializer:

    - (id)initDetailViewControllerWithIndexPath:(NSIndexPath*)indexPath
    

    ?

    I’m not familiar with a “root” property on a UIViewController, what is that? It seems to be an attempt to reference the first view controller from the detail view controller. Have you checked to see what self.root.path.row is returning?

    Anyway the path property of your first view controller is independent of what ever cell is selected the way you have your code. It is simply set to the indexPath of the last cell that is loaded. If you did want to some how access this property from your detail view controller, it would have to be set in the didSelectRowAtIndexPath method, not the cellForRowAtIndexPath method to be accurate.


    I think that if you set the path in didSelectRowAtIndexPath your way should work. But to write the custom initializer, add a property to your detail view controller called path, and then add a custom initializer to the detail view controller like this:

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andIndexPath:(NSIndexPath*)indexPath
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            self.path = indexPath;
        }
        return self;
    }
    

    and call this from the didSelectRowAtIndexPath method of the first view controller using

    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:nil bundle:[NSBundle mainBundle] andIndexPath:indexPath];
    [self presentViewController:detailViewController animated:YES completion:nil]; 
    

    (if you’re not initializing from a xib, customize which ever initializer that you’re using).

    Or, instead of passing in the index path, you could pass in an NSDictionary containing the data that you need in the detail view controller (the title and the text).

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

Sidebar

Related Questions

I have a split view-based app that presents a master-detail interface, and uses a
I have created split view based ipad app, where master view is table view
I have created a table view controller sort of a master-detail approach, when I
Background: I have a Master-Detail view split view controller. In detail table view, I
I am looking to make a Master Detail View. I have two tables tbFamily
I have a table view with numerous cells. When I press one, a tick
I have a table view controller with (among others) a cell that is to
I have a table view with a custom cell ( UISwitch on every cell
I have a Master Table and a Detail Table(like Categories and Products) in SQL
I have a Master/Detail view which opens a popover view via storyboard segue. There

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.