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?

Richard Knop
  • 81,041
  • 149
  • 392
  • 552
  • 1
    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 Apr 03 '12 at 21:21
  • possible duplicate of [#import using angle brackets < > and quote marks " "](http://stackoverflow.com/questions/1044360/import-using-angle-brackets-and-quote-marks) – jscs Apr 03 '12 at 22:21
  • See also [@class vs. #import](http://stackoverflow.com/questions/322597/objective-c-class-vs-import) – jscs Apr 03 '12 at 22:22

1 Answers1

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

Community
  • 1
  • 1
chikuba
  • 4,229
  • 6
  • 43
  • 75