在iOS7下 使用@import代替#import
2015-10-25 12:08
363 查看
原文链接:http://www.th7.cn/Program/IOS/201404/188338.shtml
在xcode 5 下,为了更易于开发,增加了modules和 auto-linking 这两个新特性。用 @import 来增加框架 到项目中比用 #import会更有效. 我们来看看为什么:
"Modules for system frameworks speed build time and provide an alternate means to import APIs from the SDK instead of using the C preprocessor. Modules provide many of the build-time improvements of precompiled headers with less maintenance or need for optimization.
They are designed for easy adoption with little or no source changes. Beyond build-time improvements, modules provide a cleaner API model that enables many great features in the tools, such as Auto Linking."
Modules and auto-linking 默认情况下是enabled的。 如果是旧的项目,你可以通过设置"Language - Modules." 来设置Enable Modules 和Link Frameworks Automatically 为Yes。
另外一个使用moudules的好处是你再也不用去链接你的framework到你的项目了。例如,在以前,如果你要使用MapKit这个框架,你要这样做1)
使用语句 #import <MapKit/MapKit.h> 导入框架2) 去到项目的build phases 设置项,找到MapKit.framework.并加入到Link Binary With Libraries里面。如果使用modules的话,只需要加入语句 "@import MapKit;" 你就可以开始使用了,根本不需要链接到你的项目。
在xcode 5 下,为了更易于开发,增加了modules和 auto-linking 这两个新特性。用 @import 来增加框架 到项目中比用 #import会更有效. 我们来看看为什么:
"Modules for system frameworks speed build time and provide an alternate means to import APIs from the SDK instead of using the C preprocessor. Modules provide many of the build-time improvements of precompiled headers with less maintenance or need for optimization.
They are designed for easy adoption with little or no source changes. Beyond build-time improvements, modules provide a cleaner API model that enables many great features in the tools, such as Auto Linking."
Modules and auto-linking 默认情况下是enabled的。 如果是旧的项目,你可以通过设置"Language - Modules." 来设置Enable Modules 和Link Frameworks Automatically 为Yes。
另外一个使用moudules的好处是你再也不用去链接你的framework到你的项目了。例如,在以前,如果你要使用MapKit这个框架,你要这样做1)
使用语句 #import <MapKit/MapKit.h> 导入框架2) 去到项目的build phases 设置项,找到MapKit.framework.并加入到Link Binary With Libraries里面。如果使用modules的话,只需要加入语句 "@import MapKit;" 你就可以开始使用了,根本不需要链接到你的项目。
相关文章推荐
- ios NSString拼接方法总结
- (iOS)手动内存管理01
- 类簇在iOS开发中的应用
- 自学 iOS 开发的一些经验
- iOS开发如何提高
- iOS开发语言
- iOS程序崩溃 NaN: [nan 40]'
- iOS开发日记36-iOS中的依赖注入
- 作IFRAME于iOS您的设备上支持滚动
- IOS中 Block简介与用法(一)
- iOS开发中常见的解析XML的类库以及简要安装方法
- iOS JSON的选项NSJSONReadingMutableLeaves
- iOS中触摸事件响应者链条
- ios返回圆形图片
- iOS多线程实现3-GCD
- iOS获取.ipa程序包
- iOS开发常用第三方开源框架介绍
- iOS 9和xcode7设置
- iOS开发--手把手教你制作音乐播放器
- ios应用数据存储的常用方式与沙盒