Hello , i have poem application , my poem titles show on table view .. i have 495 cells based on Plist file, each cell have specific title , the poets show with navigation controller on AnotherViewController ., and i implement UISearchBar [based on iPhone beginning Development book]
before i implement UISearchbar and changed plist file when user choose Poems 2 the the result was Poem 2 on AnotherViewController , but now i added some to my Plist file each poems have index letters .
the search result is fine but when user choose one of poems the AnotherViewController show wrong poem like this :
Before :
Cell 4 (Poem4) == Poem 4 (AnotherViewController)
Now :
Cell 24 (Poem24) == Poem 11 (AnotherViewController)!!!!!
my codes on Main Table view :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (!anotherViewController) {
anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
anotherViewController.navigationItem.title=[subTitle objectAtIndex:indexPath.row];
[self.navigationController pushViewController:anotherViewController animated:YES];
[anotherViewController loadPoems:indexPath.row];
}else {
[keys objectAtIndex:indexPath.row];
[anotherViewController loadPoems:indexPath.row];
anotherViewController.navigationItem.title=[subTitle objectAtIndex:indexPath.row];
[self.navigationController pushViewController:anotherViewController animated:YES];
}
}
my code that show poem on viewContorller :
- (void) loadGhazal:(int)gh{
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"fal%d",gh+1] ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
[self.webView loadHTMLString:htmlString baseURL:nil];
}
i know this is becuase of : gh+1
how can fix this ? and my WebView show poems based on poems on (NSMutableArray *keys;
)?