开发者

Xcode 4 compiler doesn't see my instance variable

So I'm working on iPhone and everything is going swell. Except for the last two hours. I was editing some class, then saved and built and suddenly I had tons of errors in another class implementation file. It seems that all the errors have to do with class members (variables) because the only errors I have are "object undeclared", those objects being the class members. Syntax is ok and all, so I believe it isn't anything like that. Did anyone have this problem before?

Example:

Foo.h

@interface Foo : NSObject
{
@private
    int m_1;
    NSString *m_2;
    NSDictionary *m_3;
}

-(id) init;
-(void) dealloc;
-(int) bar;
-(int) barWithFoo:(Foo *)foo;

@end

Foo.m

#import "Foo.h"

@implementation Foo

-(id) init
{
    return self = [super init]; 
}

-(void) dealloc
{
    // code
}

-(int) bar
{
    if (m_1 > MAX_DECL) /* error here, m_1 undeclared */
    {
        // do stuf开发者_如何学运维f
    }

    NSLog(m_2); /* error here, m_2 undeclared */
}

// etc...

@end


A bit unspecific question, it's hard to help with this info available... However, I'd check #import declarations to make sure all files are included. Also, make sure you haven't renamed a class (it can be a typo) and both declaration in .h and definition in .m have the same name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜