【问题标题】:No declaration of property ... found in interface - But there is没有属性声明......在接口中找到 - 但是有
【发布时间】:2011-11-28 18:13:17
【问题描述】:

我有以下错误:在界面中找不到“窗口”的声明。 虽然当我看的时候有一个......我可能错过了一些愚蠢的东西,但找不到它。

PlanetoidsAppDelegate.h

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

@interface WebViewExampleAppDelegate : NSObject  {
    NSWindow *window;
    IBOutlet WebView *webView;
}

@property (assign) IBOutlet NSWindow* window;
@property (nonatomic, retain) IBOutlet WebView* webView;

@end

PlanetoidsAppDelegate.m

#import "PlanetoidsAppDelegate.h"

@implementation PlanetoidsAppDelegate

@synthesize window; //<-- error here
@synthesize webView; //<-- error here (well, the same one for webView that is...)

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}

- (void)awakeFromNib {
    NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
    NSString *htmlPath = [resourcesPath stringByAppendingString:@"/Planetoids/Planetoids_Game.html"];
    [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]]; //<-- error: webView undeclared, what makes sense considdering the other errors :P
}

@end

这里的任何人都可以看到错误吗?

【问题讨论】:

    标签: xcode macos


    【解决方案1】:

    你的接口是WebViewExampleAppDelegate,但你的实现是PlanetoidsAppDelegate。这些必须匹配。

    【讨论】:

    • 它工作得非常好 :D 虽然还不能接受它,因为你回答得太快了 :o 虽然现在接受了 ;)
    【解决方案2】:
    @interface WebViewExampleAppDelegate : NSObject  in .h
    
    @implementation PlanetoidsAppDelegate in .m
    

    两个完全不同的类。您需要实现 WebViewExampleAppDelegate.m 并在该类中综合这些方法。

    另外,为此:

    @interface WebViewExampleAppDelegate : NSObject  {
        NSWindow *window;
        IBOutlet WebView *webView;
    }
    

    试试

     @interface WebViewExampleAppDelegate : NSObject  {
            UIWindow *window;
            IBOutlet WebView *webView;
        }
    

    【讨论】:

      猜你喜欢
      • 2016-06-26
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 1970-01-01
      • 2015-11-05
      • 2018-03-03
      • 2012-12-14
      • 2020-04-29
      相关资源
      最近更新 更多