0
votes

Alright, so this is my first post on this website and I love the fact that this site is so popular. It provides great advice for new programmers. So I recently took up iOS programming and I have hit my first "unsolvable road block"

I am using xCode 4.3.3.

My setup/ problem:

I have a table view controller that has three cells: "all videos", "recent videos", "bookmarked videos". depending on the cell that was selected, a different table view controller loads. simple enough.

I have connected my segues from the table view controller itself to the other table view controllers and not from the prototype cells.

I have added the appropriate identifiers to each segue in my storyboard. "all", "recent", "bookmark".

my code for

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *titleOfCell= [[[tableView cellForRowAtIndexPath:indexPath]textLabel]text];
NSString *identifer;
if ([titleOfCell isEqualToString:@"Search All Videos"]) {
    identifer=@"all";
}
if ([titleOfCell isEqualToString:@"Recently Viewed"]) {
    identifer=@"recent";  

}
if ([titleOfCell isEqualToString:@"Bookmarked"]) {
    identifer=@"bookmark";

}
[self performSegueWithIdentifier:identifer sender:self];
}

. I run the code and click a cell and it gives me NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier '_'

for every single cell! I'm tearing my hair out. Any ideas?? I have quadrupled checked for typos.

2

2 Answers

1
votes

Connect the segues to the view controller is not the problem, the problem is how you "read" the titleOfcell

add .section.row to "... cellForRowAtIndexPath:indexPath ..."

0
votes

The problem lies with the fact that you have connected the segue to the tableView instead of the cells.

For the question that you posted, if the number of cells is fixed, you can segue directly from the cells to different view controllers and name the segue identifiers accordingly. There is no need for any coding.