Objective-c: Open URL in WebView (Mac)

user3047736

I'm having a problem with opening a URL in WebView. Haven't programed with objective-c in awhile and it looks like what I'm coding has depreciated. The application opens, loads the URL but crashes with this error

Thread 1:EXC_BAD_ACCESS (code=1, address=0x20)

I originally used this to help me program in the past: [How to load URL on launch in a WebView (OSX project)?

Here's the code:

AppDelegate.h

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate> {
    WebView *myWebView;
}

@property

(retain, nonatomic) IBOutlet WebView *myWebView;


@end

AppDelegate.m

#import "AppDelegate.h"
#import <WebKit/WebKit.h>

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSString *urlText = @"http://google.com";
    [[self.myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
    return;
    // Insert code here to initialize your application
}

@end

I receive a warning in AppDelegate.m before I build

Autosynthesized property 'myWebView' will use synthesized instance variable '_myWebView', not existing instance variable 'myWebView'

How can I fix this?

TheAmateurProgrammer

Delete your declaration of WebView *myWebView; insider your curly brackets, that's not necessary.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Open url in webview - phonegap

Android open URL in WebView

C on a Mac: trying to use 'open' does not actually open the url

Autozoom webview scrollview in Objective C

Open and encrypted url using webview

How to open url in webview activity

How to include WebView in Objective C without crashing

button in webView execute Objective C method

Issue with open Google Map URL in WebView?

NativeScript WebView open url in default browser

Open offline jpg-images in a command-line-application in Objective-C under Mac OS X 10.6.8 and Xcode 3.2.6

Asynchronous loading of URL in Objective C

Calling Java library from Objective C on Mac

Compiling Objective-C in terminal on Mac OS

How to minimize the window in mac using objective c?

Compiling Objective-C code on mac terminal

OpenGL draws nothing on Mac, Objective-C

Compile Objective-C On An Apple Mac Server

Java how to open url with command on Mac?

Do not allow to open UIPickerview in Objective C

Android Appcelerator Get URL from remote URL in webview and open it in devices default browser or a new webview

In Xcode (Mac), How to make textfield update to WebView URL (Cocoa)

Send device token from viewDidLoad to webView Objective C

Receive message from JavaScript WebView in Objective-C

- (BOOL)webview: doesn't run in objective c xcode

Objective-C WKWebView: didFinish not triggering when WebView finishes loading

Flutter Web: webview_flutter plugin failed to open url scheme

List row onclick to open url from Parsed xml in webview

JavaFX stop opening URL in WebView - open in browser instead