Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Genady Novak
5,164 Points@class "className" VS #import "className.h"
In one of the diary app header files we used @class THDairyEntry instead of #import "THDairyEntry.h". What is the difference between this to methods?
1 Answer
Jan Aart Schipper
2,591 PointsIn my understanding: (don't listen to me i'm a newbie) you use @class so you can save time. You use @class in your .h file, so you're telling: compiler, here comes a class and treat it that way. And #import do you use in the .m file. Because you don't have to 'use' the object in the header file (like running methods on it). You're only importing the whole file, in the file where you're using the object.
Genady Novak
5,164 PointsGenady Novak
5,164 PointsI'm little bit confused, as far as I know we import header files to be able to create an new object from the same king of the header file. I'm not really sure why we use @class "className"