cstack
cstack

Reputation: 2232

How does XCode find classes without headers?

I'm trying to get rid of unneeded headers in my XCode project by taking them out one at a time and seeing if they cause a compiler error.

Sometimes, I can take out a header that declares a class, and Xcode still lets me use it.

For example, I took out #import "Chartboost.h", but there was no error on the line Chartboost *cb = [Chartboost sharedChartboost];

Option-clicking on Chartboost says it is declared in NSObject.h

How can my code still compile when I'm not importing the header file!?

Upvotes: 0

Views: 142

Answers (2)

T. Benjamin Larsen
T. Benjamin Larsen

Reputation: 6393

You are importing Chartboost.h, but through one of the other imported headers. This way you don't need to clutter up every class header with an endless number of header-files. Too bad XCode isn't better at telling us which headers are already available...

Upvotes: 2

Dhruv Goel
Dhruv Goel

Reputation: 2765

If you're not importing Chartboost.h then Chartboost *cb = [Chartboost sharedChartboost]; will most definitely give an error.The only possible explanation is that you might be importing some other file which in turn might be importing Chartboost.

Upvotes: 1

Related Questions