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?

相关文章
相关标签/搜索