문제

I'm new in Xcode. I'm working with Xcode 5.1.1. under OS X 10.9.2. I want to do a very simple Mac app to understand how to load URL in WebView at launch. After reading several sources (including questions from StackOverflow) I've tried about 10 different ways and finished with the same result - after Build&Run there is no windows on the screen. The error messages were:

  • signal SIGABRT, argc = 3 (of main())
  • in Console area: * 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:

In IB I created the WebView window and created an outlet zzz (I tried to ctrl-drag from AppDelegate to WebView and vice-versa). So here is a code I finished with:

//  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/"];
// I tried to put this code into awakeFromNib procedure too
}
@end

I tried to play with the code in applicationDidFinishLaunching/awakeFromNib like this:

NSString *urlAddress = @"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[self.zzz mainFrame] loadRequest:requestObj];

but I understand that is the same as [self.zzz setMainFrameURL:@"http://www.google.com/"];

The same error! Strrange! What's wrong?

Thanks.

도움이 되었습니까?

해결책

You have not added the Webkit Framework to your project. Go to Project -> Target -> Build Phases and in section Link Binary with Libraries add Webkit framework.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top