Objective-C中 #include 和 #import 的區別

因爲 Objective-C 兼容 C 語言,因此導入文件時,objective-c

能夠使用 #include,也能夠使用 #import (Objective-C 新增的)spa

如:code

#include <stdio.h>

//

blog

#import <Foundation/Foundation.h>

//

區別:
#include 重複導入是會屢次導入相同的文件;get

而 #import 只會導入一次,
不過通常的使用習慣是,若是是引入 C 語言就使用 #include, 若是是引入 Object-C 語言就是用 #importio

 

參考:class

what's the difference between import and include in Objective-C?

What is the difference between #import and #include in Objective-C?

相關文章
相關標籤/搜索