I have read in a couple of places that it is advisable to use declarations like @class Something in header files and only importing these classes in the .m file to save compile time.
Is that really still necessary and makes compiling faster with LLVM Clang or was the compile time advantage only valid for older compilers like (old versions of) GCC?
Accidentally you can get circular import:
// A.h
#import "B.h"
// B.h
#import "A.h"
Preprocessor will include B.h in A.h, which in turn include A.h (because B.h imports it), which in turn import B.h again, etc. ad infinitum.
@class statements prevent that accidental error, since error caused by circular import is really REALLY unintuitive (speaking from personal experience and backtrace/error inspections).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With