I’ve made a new project as a Single View iOS Application in Xcode. I’ve created a custom class named WebView extending UIWebView. In the storyboard, I’m adding a WebView to the ViewController and then making an IBOutlet to the WebView in the ViewController.h. Instead of using UIWebView class for the IBOutlet, I’m using my cusom WebView class and is importing its header-file in ViewController.h as well. Now my ViewController is connected to the Web VIew of class WebView.
Next, I would like my WebView to have a reference to the UIViewController. I then import the ViewController.h in my WebView.h, but then I start getting some compiler errors like:
Unknown type name ‘WebView’; did you mean ‘UIWebView’?
I guess the problem is, that ViewController.h imports WebView.h and WebView.h imports ViewController.h. Is it not possible to make cross import in Objective-C?
In WebView.h and ViewController.h, instead of importing each file, you should instead predeclare the needed classes, then do the actual importing inside the .m (implementation) files.
WebView.h
WebView.m