Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

didSelectRowAtIndexPath confusion???

EvilElfEvilElf Posts: 10New Users
I followed a tutorial on how to make a table view.
when I run the app it doesn't continue to the detailViewController (dvController) when i click at a cell. but if i first activate the searchfield and then deactivate it, it does continue to the DetailViewController when i click at cell.

This is how the didSelectRowAtIndexPath method looks like:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *selectedCountry = nil;
if (searching)
selectedCountry = [copyListOfItems objectAtIndex:indexPath.row];
else {
NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@\"Countries\"];
selectedCountry = [array objectAtIndex:indexPath.row];
}
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@\"DetailView\" bundle:[NSBundle mainBundle]];
dvController.selectedCountry = selectedCountry;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}




Please Help!
Thanks!
Post edited by EvilElf on

Replies

  • RickSDKRickSDK Posts: 634Registered Users
    hard to tell what you mean. does it crash? or just highlight the cell and do nothing?

    try adding a logging statement:
    NSLog(@"%@", selectedCountry);
    right after your if/then statement to see what that value is.

    also, i don't think you want the dvController = nil; line in after you release a variable.
  • ChickenrigChickenrig Posts: 12New Users
    If you place a breakpoint at the beginning of the method and run, does it get entered?

    I'm in slight disagreement with the previous poster though (sorry, previous poster).
    Setting to Nil after release is good practice as it prevents you from accidentally referring to memory that may no longer be valid. Prior to ARC I used to just use a macro "#define RELEASE(X) [X release]; X=Nil;" and then just call RELEASE(myVar).
  • EvilElfEvilElf Posts: 10New Users
    Yes, it just gets highlighted.
    precisely where should i put the NSLog? If I put it after the if statement I get errors like "expected expression before 'else'" and "'dvController' undeclared". And if i put it after the else statement nothing happens, just the same problem as i had before.

    Perhaps its a bit difficult for u to say when you cant see the whole code but heres the whole RootViewController.h

    Thank You!
    rootviewcontrollerimplementation.txt
    1 x 1 - 16K
Sign In or Register to comment.