我有ubuntu机器并使用GNUStep编译objective-c。我写了以下代码:
#import <objc/objc.h>
#import <Foundation/Foundation.h>
#import <objc/NSArray.h>
int main ( int argc, char ** argv)
{
int ar[100] = {0};
int i;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *arr = [[NSArray alloc] initWithObjects:@"stackOverflow", @"1", @"2", nil];
NSLog (@ "Counts in the array %i", [arr count]);
@try {
NSString *str;
str = [arr objectAtIndex:1];
NSLog (@" String value is %@ ", str);
}
@catch (NSRangeException * excep)
{
NSLog (@"Reached Range caught for %@:%@" [excep name], [excep reason]);
}
[pool release];
}
但我收到以下致命错误:
致命错误:objc/NSArray.h:没有这样的文件或目录
我也试过<NSArray.h>
,但得到同样的错误。我必须提供哪条路径?