Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@class vs #import

Tags:

objective-c

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

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

like image 803
some_id Avatar asked Jul 12 '10 12:07

some_id


1 Answers

@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.

like image 106
nevan king Avatar answered Oct 20 '22 17:10

nevan king