I have code that prints out different PDFs depending on what table row is picked. I developed this using StoryBoards and use Segues. I started with prepareForSegue, and shifted to performSegueWithIdentifier because I need several segues from one TableViewController. I can either: (1) get the row value (integer) passed, buth the webView pdf load doesn’t work (with the vc2 code), or (2) I can load the webView pdf, but not pass the row value with the performSegueWithIndentifier (so only the row = 0 pdf loads). After a solid week of research and trying, I remained perplexed. There is something fundamental here that I don’t understand. Please help.
FirstViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow];
int row = [myIndexPath row];
if (row == 0){
[self performSegueWithIdentifier:@"showView1" sender:self];}
else if (row == 1){
[self performSegueWithIdentifier:@"showView1" sender:self];}
else if (row == 2){
[self performSegueWithIdentifier:@"showView2" sender:self];}
SecondViewController *vc2 = [[SecondViewController alloc]init];
vc2.row = row;
[self.navigationController pushViewController:vc2 animated:YES];
SecondViewController
if (row == 0) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"cover" ofType:@"pdf"];
pdfUrl = [NSURL fileURLWithPath:path];
NSLog(@"in SecondView Controller path =: %@", pdfUrl);}
else if(row == 1){
NSString *path = [[NSBundle mainBundle] pathForResource:@"welcome" ofType:@"pdf"];
pdfUrl = [NSURL fileURLWithPath:path];
NSLog(@"in SecondView Controller path =: %@", pdfUrl);}
[webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];