Try this:
#1 create a segue from controller to controller:
#2 Give your segue an Id for example detailSegue
.
#3 Perform the segue in didSelectRowAtIndexPath
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"detailSegue" sender:sender];
}
#4 Implement the segue delegate:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if([segue.identifier isEqualToString:@"detailSegue"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
BookDetailViewController *detailVC = (BookDetailViewController *)segue.destinationViewController;
detailVC.bookDesc.text=[Booksarray objectAtIndex:indexPath.row];
//I uncommented that because it looks like a typo, same value 3 times?
//detailVC.BookImage.image=[Booksarray objectAtIndex:indexPath.row];
//detailVC.bookTitle.text=[Booksarray objectAtIndex:indexPath.row];
}
}
If this is the log you get:
2014-03-21 15:06:20.151 BookStore[25539:90b] BookIndex= { BookDetails = "Test test"; BookImage = ""; Books = Languages; Code = 104; }
Then you need to do it like this instead:
detailVC.bookTitle.text=[[Booksarray objectAtIndex:indexPath.row]objectForKey:@"Books"];
detailVC.bookDesc.text= [[Booksarray objectAtIndex:indexPath.row]objectForKey:@"BookDetails"];
detailVC.BookImage.image=[[Booksarray objectAtIndex:indexPath.row]objectForKey:@"BookImage"];
Or to make it shorter:
NSArray *bookAtIndex = [Booksarray objectAtIndex:indexPath.row];
detailVC.bookTitle.text=[bookAtIndex objectForKey:@"Books"];
detailVC.bookDesc.text= [bookAtIndex objectForKey:@"BookDetails"];
detailVC.BookImage.image=[bookAtIndex objectForKey:@"BookImage"];
or even shorter
NSArray *bookAtIndex = Booksarray[indexPath.row];
detailVC.bookTitle.text= bookAtIndex[@"Books"];
detailVC.bookDesc.text= bookAtIndex[@"BookDetails"];
detailVC.BookImage.image= bookAtIndex[@"BookImage"];