@import VS #import

来源:互联网 发布:tumblr类似的软件 编辑:程序博客网 时间:2024/06/04 18:17
项目中用 @import 来增加框架比用 #import会更有效,也更简洁一些

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;" 你就可以开始使用了,根本不需要链接到你的项目。

参考文章:[1]http://www.th7.cn/Program/IOS/201404/188338.shtml
0 0