Different ways of importing

Go To StackoverFlow.com

1

What is the difference between:

#import <Twitter/Twitter.h>

And:

#import "Twitter/Twitter.h"

Also, what is:

@class SomeClass

I am quite confused. Which one should I use?

2012-04-03 21:15
by Richard Knop
The first two differ exactly as they do for #include in C. The third is the moral equivalent to class SomeClass in C++ - Hot Licks 2012-04-03 21:21
possible duplicate of #import using angle brackets < > and quote marks " "Josh Caswell 2012-04-03 22:21
See also @class vs. #importJosh Caswell 2012-04-03 22:22


2

You usally use the <> to say that the header is OUTSIDE your project, and not one of your own files. If it is your file you use "" instead. This is mostly to make it a bit more clear to yourself and other people.

In your case the use of <> is the better way to go.

The "class" keyword is used for forward declaration. In c++ it speeds up compilation and I usually use it instead of having a recursive dependency. For example if you have header A.h including B.h and B.h needs to include A.h. Instead I forward declare class A in B or whatever seems most suitable.

This question would explain it a bit too since I've only used forward declaration in C++.

@class vs. #import

2012-04-03 21:18
by chikuba
Ads