Home > Software design >  Xcode: Cannot create a delegate Outlet
Xcode: Cannot create a delegate Outlet

Time:11-27

This is an Objective-C app and I'm working with Xcode 14. I'm trying to migrate deprecated UIWebView to WKWebView and I've already replaced all UIWebView references in code by WKWebView, but I'm stuck in the storyboard part (bear in mind I'm new to iOS development).

What I'm trying to do is to add a WKWebView to the SB, then replicate all properties of the current UIWebView and finally remove the UIWebView.

In the following screenshot you'll see in the right pane of the Storyboard that the current UIWebView has a delegate outlet:

Here you'll see a delegate outlet in UIWebView

But I don't know hot to replicate this delegate outlet in the WKWebView that is below. I have to say I don't k ow what is a delegate in this context exactly, but I'm just trying to replicate properties of the current WebView.

How to create a delegate outlet for the WKWebView?

CodePudding user response:

You can give your WKWebView an outlet connection for an outlet that it actually has. A WKWebView does not have a delegate property. Therefore it does not have a delegate outlet.

What I'm trying to do is to add a WKWebView to the SB, then replicate all properties of the current UIWebView and finally remove the UIWebView.

Well, stop trying to do that. A WKWebView is very different from a UIWebView. You should not look to "replicate" anything about a UIWebView using a WKWebView. Use the WKWebView as a WKWebView.

For one thing, all your code interactions with this view will have to be rewritten completely. You cannot just slot the WKWebView in place of the UIWebView as if they were just two names for the same thing.

  • Related