#import <Foundation/Foundation.h> considered incorrect


#1

I found that the following program, based on the NSDate examples in chapter 12 to fails to compile with 3951 errors, using XCode 3.2.6:

#include <stdio.h>
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
// @autoreleasepool
{

}

return 0;

}

The problem seems to be that that the import statement is incorrect, should it not be:

[color=#40FF40]#import <CoreFoundation/CoreFoundation.h>[/color] ?


#2

I suspect that the C compiler (not the ObjC compiler) is unhappy about this. Is the file a .m file or a .c file? (It should be a .m file)


#3

I got it working, I had been selecting ‘core foundation’ instead of ‘foundation’ in the project setup wizard. Thanks.


#4

Thank you. It works now.

I have been choosing Type “C” while creating a new project (after developing the C example in earlier chapter). This is wrong. :blush:
I chose Type “Foundation” and main.m. It works perfect now.