Answer the question
In order to leave comments, you need to log in
Trouble loading URL in WevView when running app in Xcode?
Hello.
I am new to Xcode. I am working on Xcode 5.1.1. under Mac OS X 10.9.2. I wanted to make a simple poppy application to understand how the URL is loaded into the WebView object after the application starts. After reading various sources (mostly StackOverflow), I made a dozen attempts, ending with the same thing: after Build & Run, the application window does not appear and error messages are issued:
- signal SIGABRT, argc = 3 (of main())
- on the console: * ** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)'
- libc++abi.dylib: terminating with uncaught exception of type NSException
What I did: I created a WebView object in the application window, created an outlet zzz (moreover, I dragged both from the AppDelegate to the WebView and vice versa - is there a difference?)
The code is as follows:
// AppDelegate.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (retain, nonatomic) IBOutlet WebView *zzz;
@end
// AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self.zzz setMainFrameURL:@"http://www.google.com/"];
// пробовал также переместить этот код в awakeFromNib
}
@end
NSString *urlAddress = @"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[self.zzz mainFrame] loadRequest:requestObj];
[self.zzz setMainFrameURL:@"http://www.google.com/"];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question