Importing HomepwnerItemCell.h


#1

On pg 303 we are told to import HomepwnerItemCell.h into the header file ItemsViewController.h.

It is not clear to me why we are importing HomepwnerItemCell.h into the header file for ItemsViewController rather than the implementation file?

Looking back I see that some of the time we imported into the header file and other times we imported into the implementation file. In general how do we know whether to import a class into another classes header or implementation file?


#2

[quote]…In general how do we know whether to import a class into another classes header or implementation file?
[/quote]
short answer: if you can compile using only forward declared types in a header file, then you don’t need to import in the header file; just import in the implementation file.


#3

Thanks, that’s how I understood it. But thus far Homepwner seem to compile just fine, at least for me, using the forward declaration @class for HomepwnerItemCell in ItemsVeiwController.h. I’m trying to understand why the authors specifically choose to import the header file instead of using @class?

In general I’m tying to understand if there are special cases in which you might want to deviate from the approach given in your short answer?