库文件(AppDelegate.h):
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
@private
__unsafe_unretained NSWindow *window;
__unsafe_unretained WebView *wview;
}
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet WebView *wview;
@end
Xcode 没有编译我的代码,在我在私有中添加 __unsafe_unretained 之前(具有分配属性的属性 'window' 的现有实例变量 'window' 必须是 __unsafe_unretained )。
主文件(AppDelegate.m):
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window;
@synthesize wview;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[wview mainFrame]loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: @"http://vk.com"]]];
}
- (IBAction)wview:(id)sender {
[[wview mainFrame]loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString:@"http://vk.com"]]];
}
@end