I just noticed that when I create iPhone application using standard templates in Xcode (View Based Application, Window based application etc) the header files only import UIKit.h (and not Foundation.h). So if the Foundation.h file is not imported, how can one use Foundation classes like NSString, NSArray etc in the program ? Shouldn't it be throwing an error?
It is imported in the precompiled header file (extension .pch
) in your project.
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
As to why UIKit.h
appears to have two import lines per file since it also shows up above, though, I'm not too sure. It shouldn't matter anyway, as the second #import
line won't cause UIKit to be included again if it's already included in the precompiled header file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With