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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:06:38+00:00 2026-05-25T11:06:38+00:00

I am implementing an a UITableView and have the – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

  • 0

I am implementing an a UITableView and have the - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method implemented and within that method I have if loops (below):

NSInteger row = [indexPath row];

if (self.someDetailViewController == nil) {
    if (row==0) {
        OneTableViewController *aDetail = [[OneTableViewController alloc] initWithNibName:@"OneDetail" bundle:nil];
        self.oneDetailViewController = aDetail;
        [aDetail release];
    } else if (row==1) {
        OneTableViewController *aDetail = [[OneTableViewController alloc] initWithNibName:@"TwoDetail" bundle:nil];
        self.oneDetailViewController = aDetail;
        [aDetail release];
    }
}

However each time I select something in my table view (let’s say row 0) I am taken to the secondary view (OneDetail) and then when I go back and select another row (row 1) and I expect to go to the other view (TwoDetail) however I am taken to OneDetail (to original row that was selected first) – how can this be when the user taps another row they are taken to the first row’s secondary view that was originally tapped. This also happens vice versa (i.e. selecting row 1 and being taken to TwoDetail and then going back and selecting row 0 and also being taken to TwoDetail not OneDetail…

I was wondering if anyone knew how to ‘restart’ an if loop when the user presses the back button or how to overcome my issue in some other fashion. Thanks so much in advance!

  • 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-25T11:06:39+00:00Added an answer on May 25, 2026 at 11:06 am

    I suspect that the second time you enter the method, this check is returning false:

    if (self.someDetailViewController == nil)

    Thus, you never get into the part where you check which row you’re on, and you’re permanently stuck with whichever one you set first.

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

Sidebar

Related Questions

When I touch (Touch Up) a UITableViewCell my ViewController's UITableViewDelegate method - (void)tableView:(UITableView *)tableView
I'm implementing the didSelectRowAtIndexPath: method in a tableviecontroller implementation. I get a conflicting type
I'm implementing a UITableView that has the index along the right hand size as
When implementing Quicksort, one of the things you have to do is to choose
I am implementing exception handling for our BizTalk services, and have run into a
I'm implementing a UITableView where the number of rows for a given section is
I am trying to implement a Core Data backed UITableView that supports indexing (eg:
I have a UIView (created in IB) with a grouped UITableView as a subview.
I am implementing an optional delegate method on the Cocoa Touch API. What I
Quick question here. I'm implementing a UITableView with cells, some of the cells contain

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.