关于实例变量和奇怪的错误超类 [英] Strange error regarding instance variables & superclass
问题描述
我有一些代码,我的类从一个超类继承,一切都一直工作到现在。我得到一个错误,当我尝试使用任何超类变量,说他们是未声明(首先在此函数中使用)。它只发生在我的一个子类,&它看起来完全一样的其他人。我想知道是否有任何明显的我应该知道(对Objective-C是新的)。基本代码如下 -
I've got some code where my classes inherit from a superclass, and everything has been working fine till now. I'm getting an error whenever I try to use any of the superclass variables, saying that they are undeclared (first use in this function). It's only happening in one of my subclasses, & it looks exactly the same as the others. I'm wondering if there's anything obvious which I should know about (being quite new to Objective-C). The basic code is like -
@interface mySuperClass : UIViewController {
BOOL myVar;
}
然后 -
@interface mySubClass : mySuperClass {
}
@implementation mySubClass {
-(void)someMethod {
myVar = YES; // error here
}
@end
任何帮助非常感激 - 如果你需要更多的信息,让我知道!感谢。
Any help much appreciated - if you need more info, let me know! Thanks.
推荐答案
我刚刚遇到一个非常类似的奇怪的错误,我不能再访问属性在我的超类, givine我编译器错误说(*)undeclared(首次使用此函数)。但是我过去没有任何问题...
I just got over a very similar strange error where I could no longer access properties in my superclass, and xcode was givine me compiler errors saying "(*) undeclared (first use in this function)". However I had not any problems in the past...
问题是,我在我的.m文件的顶部引入了错别字,而xcode编译器输出是误导我。具体来说,我有@synthesize语句,其中的属性拼写错误,无论是在synthesize语句或在头文件中的相应变量。
The problem was that I had introduced typos at the top of my .m file and the xcode compiler output was misleading me. Specifically I had @synthesize statements where the properties were misspelled, either in the synthesize statement or in the corresponding variable in the headerfile.
如果您有@synthesize语句或其他声明,请使用精细齿梳(即您最近引入的那些行)检查它们,或者甚至注释掉块
If you have @synthesize statements or other declarations, examine them with a fine toothed comb (i.e. which lines have you introduce most recently?), or even comment out a block of them to see if you can compile again and narrow down the culprit.
再次,编译器错误是非常误导的,所以它真的很难调试。虽然像99.9%的时间的错误是我自己的。 :)
Again the compiler errors were very misleading, so it really was tough to debug. Although like 99.9% of the time the error was my own. :)
这篇关于关于实例变量和奇怪的错误超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!