2013-12-13 35 views
1

的(a)UIApplicationMain()方法是該方法的第四參數的輸入: NSStringFromClass()
(b)中NSStringFromClass()發現Foundation.h
(c)中唯一導入到的main.mUIKit.h
(d)盡我可以告訴,UIKit.h不延長Foundation.hNSStringFromClass()由UIApplicationMain()調用,但Foundation.h不在的main.m

那麼,爲什麼我當我編譯的main.m我沒有得到一個錯誤? NSStringFromClass()應該是一個無法識別的方法?

+0

如果預處理文件(有一個菜單項可以實現這一點),它將顯示編譯器最終編譯爲'main.m'的所有​​內容,包括所有導入的頭文件。如果您從文件頂部開始搜索'NSStringFromClass',則定義*必須是第一個找到的實例。 – bbum

回答

3

看一看在你的項目中* prefix.pch文件中的宏支持文件;-)

+0

非常感謝。我很抱歉我沒有更加努力。 – ramsay

3

基金會自帶的每一個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