开发者

detail item from didSelectRowAtIndexPath comes out as null

Right now I have a table with a number of PDFs listed. From the table the user can select a PDF and it will be displayed in the view. Right now when I select and item from the table it should change the detailView's detailItem to the item in the row I selected, in addition change the variable i to the selected row number.

Here is what my DidSelectRowAtIndexPath method looks like:

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    affirmaPDFViewController.detailItem = [NSString stringWithFormat:@"%@", [listOfPDF objectAtIndex:indexPath.row]];
    affirmaPDFViewController.i = indexPath.row;

    NSLog(@"%d", indexPath.row); //returns the proper value
    NSLog(@"%@", [listOfPDF objectAtIndex:indexPath.row]); //returns the proper value

    //NSLog(@"%d", affirmaPDFViewController.i); //DOES NOT return the proper value
    //NSLog(@"%@", affirmaPDFViewController.detailItem); //DOES NOT return the proper value

}

for the first two NSLog's, they display the proper information, however when i check the last two they come out with affirmaPDFViewController.i = 0 and a开发者_StackOverflow中文版ffirmaPDFViewController.detailItem = null. When i need the affirmaPDFViewController.i= indexPath.row, and affirmaPDFViewController.detailItem = the item in the row I selected.

Anyone know why they aren't coming out with the proper values?

Thanks in advance!


Your instance of affirmaPDFViewController is nil. Check the method where it's created, and remember you can set a breakpoint in the debugger to see if it's a valid object or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜