This code works at first touch. Preview starts to display (Title, Done, Actions, and blank page) and then previewController:(QLPreviewController *)previewController previewItemAtIndex:(NSInteger)index
is called again. This time [self.resultsController objectAtIndexPath:selectedIndexPath];
returns nil - My guess is the entry is no longer selected. index
is correct at 1.
The procedure:
- (id)previewController:(QLPreviewController *)previewController previewItemAtIndex:(NSInteger)index
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
Manuals *manuals = [self.resultsController objectAtIndexPath:selectedIndexPath];
NSURL *vUrl = [self locateUrl:[NSURL URLWithString:manuals.Url] ofType:[manuals.Url pathExtension]];
return vUrl;
}
If I ignore the exception - the preview continues to display the the document.
I did try to keep the last good returned selectedIndexPath, but then received the error: -[__NSArrayM indexAtPosition:]: unrecognized selector sent to instance 0x1cd52800
The question:
How can I get my resultsController object using only the passed in index?