0

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 stuff
    }

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

// etc...

@end
3
  • Could you have another Foo.h somewhere in the search path? Commented Sep 10, 2010 at 10:32
  • Are you able to reproduce the problem with the code you wrote for your question? If not, we'll need to see the actual code that produces the errors. Commented Sep 10, 2010 at 15:19
  • Also, note that Xcode 4 is under NDA, so we can't talk about it here. If something doesn't work in it, try it in Xcode 3, and if that works, you should file a bug about 4. bugreport.apple.com Commented Sep 10, 2010 at 15:20

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Yes I have checked all #import declarations and the name is correct. Also the files are in the correct folder and I am editing the correct files. I can't really post my whole class implementation file, but basically it's as I have described, btw I have edited the OP.
I guess you have tried full rebuild, haven't you? Erase all temporary files manually.
Yup, I've cleaned all targets and rebuilt several times.
Try to localize the issue. Remove the "problem" class from the project (replace it with a blank) and check whether the project will compile. If yes - insert the problem class into the new empty project and check it step-by-step.
This will sound stupid, but I just backup the contents of the files, erased them, saved them, then reverted them to the backup I made and now it works! WTF? Thanks for your help :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.