views:

19

answers:

1

I am very new to this and am trying to learn by creating a few little apps for myself. I have a navigation-based app where the user taps the row to select a film title - i then want the second view to show details of the film.

Thanks to a very helpful person here i am getting the results of the row pressed as 'rowTitle' as follows :

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *key = [keys objectAtIndex:indexPath.section]; NSArray *nameSection = [names objectForKey:key]; NSString *rowTitle = [nameSection objectAtIndex:indexPath.row]; NSLog(@"rowTitle = %@", rowTitle); [tableView deselectRowAtIndexPath:indexPath animated:YES];

I am, however, struggling to make the data at 'rowTitle' available to the 2nd view -

basically, if i can get the info - for example rowTitle is "aliens2" - i want to be able to add a new extension to the end of the string returned by 'rowTitle' in order to point to an image (if that makes sense) in the second view...

something like

tempImageName=[** this is where the info from rowTitle needs to be i suppose**]; tempImageType=@".png"; finalImageName=[tempImageName stringByAppendingString:tempImageType];

does this make sense to anyone (apologies if it doesnt - i know what i want but how to explain it is a little more awkward!)

Thanks again for any help anyone can give (and any help as to formatting these questions would be useful too obviously!!)!

A: 

You should use stringByAppendingPathExtension to add the png extension, if you really need to do that. But that depends on what you are going to do with it; you may not need the full file name just to just a file, for instance - pathForResource:ofType: can take the extension as the type argument (but imageNamed: likes the full filename).

You should add a property in your second view controller for the image name, then create and push/present the view controller in your select method.

MyViewController *vc = [[MyViewController alloc] init];
vc.imageName = tempImageName;
[self.navigationController pushViewController:vc animated:YES];
[vc release];
Paul Lynch