T
T
teddyfox2014-05-05 13:24:11
Cocoa
teddyfox, 2014-05-05 13:24:11

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

I also tried to play with the code in applicationDidFinishLaunching/awakeFromNib:
NSString *urlAddress = @"http://www.google.com/";
  NSURL *url = [NSURL URLWithString:urlAddress];
  NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
  [[self.zzz mainFrame] loadRequest:requestObj];

but it's the same (IMHO) as
[self.zzz setMainFrameURL:@"http://www.google.com/"];

What's the catch? Strange that the same error! Or a problem in the system/Xcode settings?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question