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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:22:45+00:00 2026-06-12T13:22:45+00:00

I am trying to make a simple program which involves a tableView. When I

  • 0

I am trying to make a simple program which involves a tableView. When I click on a cell in the tableView, it should reveal more information about the cell that was clicked on DetailedViewController. However, when I click the cell, it remains highlighted and it does not reveal the information of the cell. So I used NSLog() statements to identify where the program was getting stuck. NSLog() statement that I introduced in didDeselectRowAtIndexPath method indicates that I get a response for the cell that was click prior to the last one.

Any idea why is this happening? Also, why do I not see the DetailedViewController when I click the cell?

For the sake of brevity, Numbers.h contains two variable: NSString * name and int long long number. DetailedViewController is a simple VC with two labels: nameField and numberField and they are suppose to get updated when I click the respective cell.

I would sincerely appreciate any help. Thanks.

#import "SecondViewController.h"
#import "DetailedViewController.h"
#import "Numbers.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

@synthesize numberList;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    NSLog(@"loaded Nib file");
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"View Numbers";
        self.tabBarItem.image = [UIImage imageNamed:@"second"];
    }
    return self;
}

- (void)viewDidLoad
{
    NSLog(@"Loaded view controller");
    Numbers *num1 = [[Numbers alloc] init];
    Numbers *num2 = [[Numbers alloc] init];
    num1.name = @"Number 1";
    num1.number = 12345;

    num2.name = @"Number 2";
    num2.number = 23456;

    numberList = [[NSMutableArray alloc]  initWithObjects:num1,num2, nil];

    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload {
    [self setNumberList:nil];
    [super viewDidUnload];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return numberList.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

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

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndetifier];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2    reuseIdentifier:cellIndetifier];
        cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    }

    cell.textLabel.text = [[numberList objectAtIndex:indexPath.row] name];

    return cell;

}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Row selected = %d", indexPath.row);

    Numbers *numberToDisplay = [[Numbers alloc] init];
    numberToDisplay.name = [[numberList objectAtIndex:indexPath.row] name]; // why can I not use dot notation here?
    numberToDisplay.number = [[numberList objectAtIndex:indexPath.row] number]; // why can I not use dot notation here?

    DetailedViewController *detailedViewController = [[DetailedViewController alloc] initWithNibName:@"DetailedViewController" bundle:nil];
    detailedViewController.nameLabel.text = numberToDisplay.name;
    detailedViewController.numberLabel.text = [NSString stringWithFormat:@"%lli", numberToDisplay.number];

    [self.navigationController pushViewController:detailedViewController animated:YES];
}

@end
  • 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-12T13:22:46+00:00Added an answer on June 12, 2026 at 1:22 pm

    Change didDeselectRowAtIndexPath for didSelectRowAtIndexPath. That should give you information about the cell that’s currently being selected.

    The cell you’re getting from didDeselectRowAtIndexPath is the row that gets deselected, after you selected a new cell. That’s why it’s behind.

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

Sidebar

Related Questions

I am trying to make a simple program that could open a new activity
I've been trying to make a simple program that takes the user input, until
I'm new to android and I'm trying to make a simple android program that
I am currently trying to make a very simple C program for school that
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I am trying to make a simple program to put data from a database
I am trying to make a simple program with SFML. So far I have
I'm new to iPhone programming, and I'm trying to make a simple program without
I am trying to make a jar of a simple inventory program using ant

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.