为什么不识别此实例变量?

时间:2011-08-31 22:12:06

标签: objective-c

在我的.h:

@class PanelController;

@interface PanelController : NSWindowController <NSWindowDelegate>
{
    NSURL *zURL;
}

@property (nonatomic, assign) NSURL *zURL;

@end

在我的.m:

@synthesize zURL;

...

- (IBAction)openBrowser:(id)sender {
    self.zUrl = [zOpenPanel URL];
}

错误:

zURL not found on object PanelController 

1 个答案:

答案 0 :(得分:10)

因为Objective-C区分大小写。

您使用的是self.zUrl,但应该是self.zURL

(另外,如果声明属性,则可能不需要实例变量声明。)

相关问题