#ifdef __OBJC__宏定义的作用

创建pch文件如下:

添加文件Tableview-Prefix.pch

 

内容如下:

 

#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

 

 

       Xcode6之后,pch预编译文件默认是不带的,这个需要我们去创建pch文件。记得在你向pch添加全局的头文件之前,莫忘#ifdef __OBJC__     #end。  

       这个宏定义的作用是保证只有OC文件可以调用pch里面的头文件,一些非OC语言不能调用,比如.cpp,.mm。

       如果不加入,那么如果代码中带有.cpp,.mm文件,那么将报错。NSObjCRuntime.h   NSObject.h    NSZone.h将会报出编译异常。

posted on 2015-10-16 20:54  &#127774;Bob  阅读(187)  评论(0编辑  收藏  举报

导航