Some Foundation Classes
The Foundation classes of Cocoa provide basic data types and utilities that will form the basis of much that you do in Cocoa. Obviously I can’t list all of them, let alone describe them fully, but I can survey a few that I use frequently and that you’ll probably want to look into before writing even the simplest Cocoa program. For more information, start with Apple’s list of the Foundation classes in the Foundation Framework Reference.
Useful Structs and Constants
NSRange is a struct of importance in dealing with some of the classes I’m about to discuss. Its components are integers (NSUInteger),
length. So a range whose
location is 1 starts at the second element of something (because element counting is always zero-based), and if its
length is 2 it designates this element and the next. Cocoa also supplies various convenience methods for dealing with a range; you’ll use NSMakeRange frequently. (Note that the name, NSMakeRange, is backward compared to names like CGPointMake and CGRectMake.)
NSNotFound is a constant integer indicating that some requested element was not found. For example, if you ask for the index of a certain object in an NSArray and the object isn’t present in the array, the result is NSNotFound. The result could not be
0 to indicate the absence of the object, because
0 would indicate the first element of the array. Nor could it be nil, because nil is
0 (and in any case is not appropriate when an integer is expected). The true numeric ...