为什么在没有导入Foundation的情况下仍然有效?

stu*_*ped 2 objective-c nsobject

NSObject当我没有导入时,为什么我仍然可以使用函数并从类中创建对象?

int main (int argc, char *argv[])  
{  
    @autoreleasepool {  
        NSLog(@"hi");
        NSArray *array = [NSArray arrayWithObject: @"hello"];
        NSLog(@"%@", array);
    }
    return 0;  
} 
Run Code Online (Sandbox Code Playgroud)

产量

2012-08-11 22:15:33.854 prog[1282:403] hi
2012-08-11 22:15:33.857 prog[1282:403] (
    hello
)
Run Code Online (Sandbox Code Playgroud)

Sky*_*leh 8

很可能你有一个导入Foundation的Precompiled/Prefix标头,因此基金会被隐式添加到每个标头中.查找名为*-Prefix.pch的文件.Xcode通常将其放在一个名为Supporting Files的组中.