Property 'dataSource' not found on object of type 'QLPreviewController *' error in Objective-C

50 Views Asked by At

I got this problem from this patch of code:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    /*
     *  get the path to the pdf resource.
     */
    
    NSString *path =
    [[NSBundle mainBundle] pathForResource:@"article"
                                    ofType:@"pdf"];
    NSURL *docURL = [NSURL fileURLWithPath:path];
    
    
    /*
     *  create the Quicklook controller.
     */
    QLPreviewController *qlController = [[QLPreviewController alloc] init];
    
    PreviewItem *item =
    [[PreviewItem alloc] initPreviewURL:docURL
                              WithTitle:@"Article"];
    self.pdfDatasource =
    [[PDFDataSource alloc] initWithPreviewItem:item];
    
    qlController.dataSource = self.pdfDatasource;
    
    
    /*
     *  present the document.
     */
    
    [self presentViewController:qlController
                       animated:YES completion:nil];
}

The line that was causing the problem is the line:

qlController.dataSource = self.pdfDataSource

Also, the iOS app I was trying to make is one that utilizes a QuickLook framework to display a document, if that helps anyone.

I got the code from a guide here. Any help?

P.S. I can't switch to Swift yet for some reasons, so I'll just keep my app as Objective-C for now.

0

There are 0 best solutions below