2011-12-28 8 views
0

それは投げるエラーを保ちます:メッセージの受信者タイプのwebFrameは、 "[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]]行の前方宣言です。 ; "CocoaのWebviewはロードされません

私の.hファイル

@interface AttendanceWizardAppDelegate : NSObject <NSApplicationDelegate> 
{ 
@private WebView *webView; 

} 
@property (weak) IBOutlet WebView *webView; 
@property (assign) IBOutlet NSWindow *window; 

@end 

マイ.mファイル

#import "AttendanceWizardAppDelegate.h" 

@implementation AttendanceWizardAppDelegate 


@synthesize Username = _Username; 
@synthesize Password = _Password; 
@synthesize webView = _webView; 
@synthesize webber = _webber; 
@synthesize window = _window; 

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{ 
NSString *urlStr = @"www.google.com"; 
[[webView mainFrame ] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]]; 
} 

@end 

答えて

2

あなたは単にあなたのヘッダファイルでWebKitのヘッダのインポートを追加する必要があります。

#import <WebKit/WebKit.h> 

あなたのコード宣言したプロパティのインスタンス変数を定義しないことで、簡略化することもできます。

ヘッダファイル(.H):

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

@interface AttendanceWizardAppDelegate : NSObject <NSApplicationDelegate> 
// No need for a iVar declaration 

@property (weak) IBOutlet WebView *webView; 
@property (assign) IBOutlet NSWindow *window; 

@end 

実装ファイル(.M):

#import "AttendanceWizardAppDelegate.h" 

@implementation AttendanceWizardAppDelegate 

// Simplified synthesize declarations (no reference to the iVar) 
@synthesize Username; // I suggest you change the name of this variable ; the convention is to start the name of your property with a lower case letter, to not confuse it with a class name 
@synthesize Password; 
@synthesize webView; 
@synthesize webber; 
@synthesize window; 

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{ 
    NSString *urlString = @"www.google.com"; 

    [[self.webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]]; // Note the use of self.webView, to use the getter you created by declaring the property 
} 

@end 
+0

輸入がありました。 – Kevrone

+0

コンパイル時または実行時にエラーがスローされますか? – Guillaume

+0

私はWebkit.hでタイプミスをしました – Kevrone

関連する問題