I am trying to pass the value of a string from an array to an instance of ImageViewer when building a table view cell, but I am getting nil values. Here is the code:
NSString *file = [[NSString alloc] init ];
file = [photoFiles objectAtIndex:indexPath.row];
ImageViewer *imageView = [[ImageViewer alloc] initWithNibName:@"ImageViewer" bundle:nil];
imageView.fileName = file;
[self.navigationController pushViewController:imageView animated:YES];
[imageView release];
Can you help me please to fix this problem?
If
imageView.fileName = fileis setting anilvalue, you probably should consider analyzing the contents of thephotoFilesarray.It could be possible that this array has no values at the
indexPath.rowindex. You should check this through the debugger, or with a log print:Edit
You could write this code in a more concise way. I.e.:
Also, you should avoid pointing to a
nilNSBundle. I.e. Change the first row to:But it should work also this way, since the class name and the Nib name are the same:
Try it and let me know if something changed.