(a) UIApplicationMain()方法中的第4个参数是方法:
NSStringFromClass()
(b) NSStringFromClass()位于 Foundation.h 中
(c) main.m 的唯一导入是 UIKit.h 。
(d)我可以说, UIKit.h 不会扩展 Foundation.h
那么,为什么我在编译 main.m 时没有收到错误? NSStringFromClass()应该是一个无法识别的方法吗?
答案 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