Objective-C中 #include 和 #import 的区别

由于 Objective-C 兼容 C 语言,所以导入文件时,

可以使用 #include,也可以使用 #import (Objective-C 新增的)

如:

#include <stdio.h>

//

#import <Foundation/Foundation.h>

//

区别:
#include 重复导入是会多次导入相同的文件;

而 #import 只会导入一次,
不过一般的使用习惯是,如果是引入 C 语言就使用 #include, 如果是引入 Object-C 语言就是用 #import

 

参考:

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

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

posted @ 2019-10-15 19:34  一菲聪天  阅读(470)  评论(0编辑  收藏  举报