tags:

views:

51

answers:

3

Hey guys,

I'll try this again. I need help in getting a third option working using a drill down table view. As it sits right now, the application shows all three in the table when the application runs, but when clicked on the second or third, it will only show the view for the third. I read some tutorials on .plist but I wanted to know if it was possible to do it using a condition set for all three. Here's the code that I have:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) 
 [details setContent:arrAutoLock];
   /*(indexPath.row == 1) 
 [details setContent:arrPasscodeLock];*/
 else 
  [details setContent:arrRestrictions];

  [[self navigationController] pushViewController:details animated:YES];
A: 

I would start by putting brackets around the statements in your different conditions. I always use brackets, but they are required if you have more than one line:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        [details setContent:arrAutoLock];
    } else {
        [details setContent:arrRestrictions];
        [[self navigationController] pushViewController:details animated:YES];
    }

Since you have three choices, you will want to have different behavior for all three:

if (indexPath.row == 0) {
    // handle first row here
} else if (indexPath.row == 1) {
    // handle second row here
} else {
    // handle third row here
}

Or you can use a switch statement:

switch (indexPath.row) {
    case 0:
        // handle first row here
        break;
    case 1:
        // handle second row here
        break;
    case 2:
        // handle third row here
        break;    
}
gerry3
Thank you VERY MUCH Gerry! That's exactly what I needed. Thanks again.
Rafa Ramirez
A: 

The words you use in your question don't make sense. You need to clarify what you mean. You say "drill down table view". What does that mean? A table view doesn't drill down. You can use table views to select rows and push new view controllers onto the navigation stack which is a "drill down", but a "drill down table view" is non-sensical.

You go on to say "the application shows all three in the table...", all three what? All three rows? All three sections? Then you say "when clicked on the second or third, it will only show the view for the third". What is "it". Are you pushing a new view controller onto the navigation stack or are you adding a new view to the view hierarchy. Views and view controllers are different things?

Finally, what does a .plist tutorial have to do with any of this? Again, its non-sensical.

My guess is that you are a non-native speaker of English and so this is your primary challenge. If you can clarify what you are wanting to do, it will make it much easier to help you.

Best regards,

Matt Long
A: 

Gerry, that is exactly the clarification that I needed. Thank you! Works perfectly now.

And Matt,

I am truly sorry if nothing of what I said in my post makes sense. Indeed, I am a non-native speaker of English, but that really doesn't count as much as the fact that I am not a PROFESSIONAL programmer, hence unfamiliar with most terms. Even more, I started to work with Objective-C just three weeks ago. The terminology that I used comes from a combination of sources: online tutorials, iPhone SDK books, etc. I guess I am making mistakes mixing up what I have read. I really appreciate the clarifications that you made.

The application shows all three MAIN ROWS when it runs, which is good because it is exactly what I need. When I said "it will only show..." I was referring to the application. And yes, I am adding a new view to the view hierarchy.

While searching for solutions, I found out that a .plist might help me achieve what I was looking for. I made reference to this only to give you guys a better idea of what I was trying to do here.

Thanks again!

Rafa Ramirez