@class vs #import [英] @class vs #import

查看:43
本文介绍了@class vs #import的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在objective-c 中使用@class 或#import 有什么区别?

What is the difference when using @class or #import in objective-c?

我看过各种教程,只有少数使用@class,而其他大多数使用#import.

I have seen various tutorials and only a few use @class while most of the others use #import.

推荐答案

@class 不导入文件,它只是告诉编译器这个类存在即使你不知道关于它,如果我使用它,请不要警告我".#import 实际上导入文件,因此您可以使用所有方法和实例变量.@class 用于节省编译时间(导入整个文件会使编译花费更多时间).如果需要,您可以使用 #import,只是构建项目需要更长的时间.

@class doesn't import the file, it just says to the compiler "This class exists even though you don't know about it, don't warn me if I use it". #import actually imports the file so you can use all the methods and instance variables. @class is used to save time compiling (importing the whole file makes the compile take more time). You can use #import if you want, it will just take longer for your project to build.

这篇关于@class vs #import的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆