0
votes

I am trying to open a PDF file within my app. But I keep getting the following error when I click on the button in the simulator.

2019-07-31 14:11:39.542087+1000 TJP:Photography Training[4508:715096] Unknown class _TtC24TJP_Photography_Training10AboutAppVC in Interface Builder file. 2019-07-31 14:11:41.020377+1000 TJP:Photography Training[4508:715096] -[UIViewController howToUseTheAppAction:]: unrecognized selector sent to instance 0x7fbd6f701d60 2019-07-31 14:11:41.024444+1000 TJP:Photography Training[4508:715096] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController howToUseTheAppAction:]: unrecognized selector sent to instance 0x7fbd6f701d60'

*** First throw call stack: ( 0 CoreFoundation 0x00000001066308db exceptionPreprocess + 331 1 libobjc.A.dylib
0x0000000104171ac5 objc_exception_throw + 48 2 CoreFoundation
0x000000010664ec94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 UIKitCore 0x000000010a4ec235 -[UIResponder doesNotRecognizeSelector:] + 287 4 CoreFoundation 0x0000000106635623 ___forwarding_
+ 1443 5 CoreFoundation
0x0000000106637418 _CF_forwarding_prep_0 + 120 6 UIKitCore
0x000000010a4c1624 -[UIApplication sendAction:to:from:forEvent:] + 83 7 UIKitCore 0x0000000109f168d5 -[UIControl sendAction:to:forEvent:] + 67 8 UIKitCore 0x0000000109f16bf2 -[UIControl _sendActionsForEvents:withEvent:] + 450 9 UIKitCore 0x0000000109f15ba8 -[UIControl touchesEnded:withEvent:] + 583 10 UIKitCore 0x000000010a4fa4e6 -[UIWindow _sendTouchesForEvent:] + 2547 11 UIKitCore 0x000000010a4fbbca -[UIWindow sendEvent:] + 4079 12 UIKitCore
0x000000010a4da30e -[UIApplication sendEvent:] + 356 13 UIKitCore
0x000000010a5aa2b3 dispatchPreprocessedEventFromEventQueue + 3232 14 UIKitCore 0x000000010a5acbd9 __handleEventQueueInternal + 5911 15 CoreFoundation 0x0000000106597db1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 16 CoreFoundation 0x0000000106597633 __CFRunLoopDoSources0 + 243 17 CoreFoundation 0x0000000106591cef __CFRunLoopRun + 1231 18 CoreFoundation
0x00000001065914d2 CFRunLoopRunSpecific + 626 19 GraphicsServices
0x000000010e7f42fe GSEventRunModal + 65 20 UIKitCore
0x000000010a4bffc2 UIApplicationMain + 140 21 TJP:Photography Training 0x00000001038897db main + 75 22 libdyld.dylib
0x0000000107a3d541 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

I followed a youtube tutorial which worked in a project on its on but as soon as tried the same thing in the app I am working on it came up with the above error. I have not done anything differently. I have triple checked all my code and connections for spelling errors.

import Foundation
import UIKit
import WebKit

class AboutAppController: UIViewController {

    let pdfTitle1 = "How to use the App"

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func howToUseTheAppAction(_ sender: Any) {
        if let url = Bundle.main.url(forResource: pdfTitle1, withExtension: "pdf") {
            let webView = WKWebView(frame: self.view.frame)
            let urlRequest = URLRequest(url: url)
            webView.load(urlRequest as URLRequest)

            let pdfVC = UIViewController()
            pdfVC.view.addSubview(webView)
            pdfVC.title = pdfTitle1
            self.navigationController?.pushViewController(pdfVC, animated: true)    }
    }

}

I expect for the PDF file to open in a new web view

1

1 Answers

0
votes

You can check in your storyboard file. I think you can missing or duplicate IBOulet. even you can forget remove old IBOulet, Which was deleted.

enter image description here