Import Question


In this chapter I noticed that in ItemsViewController.h we added (after figure 11.12):

#import "DetailViewController.h"

A by product of adding DeatailViewController to the .h meant we didn’t need to add it in the .m file as well.

Normally the BNR books tell you to use @class in the .h, and #import in the .m.

Was there a reason for doing that differently here?


In the index look for @class, on page 195 for the book version:

The book’s implementation of ItemsViewController.h doesn’t have any implementation that needs DetailViewController declarations. ItemsViewController.m does when it implements the tableView:didSelectRowAtIndexPath method. (search for DetailViewController in the .m file)

I suppose the follow up question is why have the DetailControllerView.h imported at the header file instead of .m file like BNRItemStore.h and BNRItem.h. I would guess that this makes it easier to read for items of the same level. Like if you’re looking to see what connections are made between ViewControllers you can browse the header files to see them quickly. BNRItemStore and BNRItem has more to do with the way the specific view controller is implemented.