UIApplicationMain()调用NSStringFromClass(),但不在main.m中导入Foundation.h

时间:2013-12-13 16:51:35

标签: objective-c cocoa-touch

(a) UIApplicationMain()方法中的第4个参数是方法: NSStringFromClass()
(b) NSStringFromClass()位于 Foundation.h (c) main.m 的唯一导入是 UIKit.h
(d)我可以说, UIKit.h 不会扩展 Foundation.h

那么,为什么我在编译 main.m 时没有收到错误? NSStringFromClass()应该是一个无法识别的方法吗?

2 个答案:

答案 0 :(得分:3)

查看项目支持文件中* prefix.pch文件中的宏; - )

答案 1 :(得分:3)

Foundation是在每个Xcode项目标准的预编译头中导入的:

//
// Prefix header for all source files of the <x> target in the <x> project
//

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif