Convert swift to objective c

Could someone convert this to objective c

Thanks!


https://developer.apple.com/documentation/webkit/wkwebview?language=objc


Creating a WKWebView programmatically


import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {

var webView: WKWebView!

override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()

let myURL = URL(string:"https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}}

Replies

Which bits are you having problems with?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Try this:



//  in the .h file:
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
@interface ViewController : UIViewController<WKUIDelegate>{
    WKWebView *webView;
}


// in the .m file:
#import "ViewController.h"
@interface ViewController (){  }
@end


@implementation ViewController
-(void)viewDidLoad{
    [super viewDidLoad];
    NSURL *myURl=[NSURL URLWithString:@"https://www.apple.com"];
    NSURLRequest *myRequest=[NSURLRequest requestWithURL:myURl];
    [webView loadRequest:myRequest];
}
-(void)loadView{
    WKWebViewConfiguration *webConfiguration=[WKWebViewConfiguration init];
    webView=[[WKWebView alloc] initWithFrame:CGRectZero configuration:webConfiguration];    
    webView.UIDelegate=self;
    self.view=webView;
}

Thanks!

I should have stated for mac os specifically.

And I should have stated "I only do iOS Objective C" - you will need to handle any differences.