headerView - headerView is both the name of an instance variable of type UIView described in the header file (ItemsViewController.h), and also an instance method of the NSTableView class. Inheritance for this object is UITableViewController => UIViewController => UIResponder => NSObject. It appears to be an instance method that is being overridden, but it is not a method of any class in the hierarchy. Is there something I don’t understand about NS foundation class objects and their relationship to UI objects? If I changed the name of the variable in the header file to hdrView would it all come crashing down? headerView is NOT part of the UITableViewDataSource protocol as far as listed methods go. I don’t understand the origin of this method and what causes it to be magically executed.
NSTableView is part of Cocoa, which is for the desktop. It is a view object that you can only get on a Mac application. UITableView is something similar for the iPhone. So, you can safely ignore anything from NSTableView.
Of course, that leads to the question, “Well, what does NS mean and how do I know which NS things I can use on the iPhone?”
First, the reason we use two or three letter prefixes on class names is the same reason other languages have namespaces - to make sure common words are not taken out of the list of names you can use for declaring your classes. As an example, the word “Object” is pretty common. I might have a game where I have an “Object” class that represents the base features of some visible entity in the game; it would have a position, size, color, etc. The best way to name it is simply “Object.” But, if Cocoa named its base class “Object”, we couldn’t name our class Object. (We call this problem a namespace collision.)
When Cocoa was written (or, rather, “ported” to the Mac), all of the classes were prefixed with “NS” as a shout-out to Nextstep. “Cocoa” is comprised of multiple frameworks: the two big ones being Foundation and Cocoa. Foundation makes up a lot of the base model object classes, like NSString, NSDate, NSArray, etc. Cocoa has a lot more stuff, especially view objects, like NSView, NSWindow, NSTableView, etc. However, classes from both of these frameworks were prefixed with NS.
iOS can’t use the Cocoa framework (for a variety of reasons), it instead uses the UIKit framework. Classes in the UIKit framework are prefixed with UI, as you have seen. iOS still uses the Foundation framework, though, as things like NSString and NSArray are still totally valid.
So, it is slightly confusing as to what NS things you can use. So, you’ll have to put away the idea that “NS” means you can use it. One way to fix the confusion is to turn off the Mac OS X Doc Set in the documentation browser. When you open up the doc window, it should say “All Doc Sets” next to where it says “Contains Prefix Exact”. Uncheck the Mac OS X one. Now, when you search the docs, you will only see iPhone stuff.
As for the headerView thing, its a brand new method. It gets called when the table view asks for a header view - you could rename it whatever you like.