views:

45

answers:

1

hi guys . i had questioned here : http://stackoverflow.com/questions/1675113/best-idea-for-importing-text-to-each-navigationcontroller-view

the answer was this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    PoemDetailsViewController *poemDetails = [[[PoemDetailsViewController alloc] initWithNibName:@"PoemDetailsViewController" bundle:nil] autorelease];
    poemDetails.poem = [poems objectAtIndex:indexPath.row]; // assuming you have a single dimension array with poems and a single table group
    [self.navigationController pushViewController:poemDetails animated:YES];
}

now on on the PoemDetailsViewController i create an UIWebView and writing this code :

(i know this code shows only one of my HTML files)

NSString *path = [[NSBundle mainBundle] pathForResource:@"fal1" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];

NSString *htmlString = [[NSString alloc] initWithData: 
                            [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];

now i can't find any associating between this code

poemDetails.poem = [poems objectAtIndex:indexPath.row];

to load poems on the AnotherViewController with each cell ?

i mean is every cells show their poem on the other view with Navigation Controller .

+1  A: 

The line in question:

poemDetails.poem = [poems objectAtIndex:indexPath.row];

is simply passing information about the row (poem) that was selected to the new view controller.

Typically, the "poem" will be a custom class with relevant info about the poem such as its title and the name of its HTML file, but it could just be a string (if the title & HTML filename match).

For example, you would use it here:

NSString *path = [[NSBundle mainBundle] pathForResource:poem.filename ofType:@"html"];
gerry3
so i used this :NSString *path = [[NSBundle mainBundle] pathForResource:@"poem" ofType:@"html"];but does not work
Momeks
That will (always) create the path string as "poem.html". You want the path to be dynamic (different for different poems), so you should use a variable as the path name like I suggest.
gerry3