Changes

Jump to: navigation, search

An Overview of the Objective-C Foundation Framework

2,886 bytes added, 16:36, 2 November 2009
no edit summary
== The Foundation Framework ==
The Objective-C FoundationFramework is a essentially a set of classes that are provided to speed and ease the process of developing applications using Objective-C. The framework was developed by NeXT Computer as part of the NeXTStep environment. When NeXT was acquired by Apple, Inc. the Foundation classes quickly became of basis of Mac OS X and then the iPhone development kit. For a full history of how this came to be, refer to the chapter entitled [[The History of Objective-C]]. Due to the fact that the Foundation Framework started life of part of NeXTstep, the classes that comprise this framework all begin with the letters "NS". You will recall that when we created our first class in [[An Overview of Objective-C Object Oriented Programming]] we derived our class from ''NSObject''. NSObject is a part of the Foundation Framework and as you become more familiar with the framework you will learn that most Foundation classes are derived from this class). In this and subsequent chapters we will look in more detail at some of the other classes provided by the framework. == Including the Foundation Headers == In previous chapters we have been including the header files for the Foundation Framework in our examples. This is achieved using the following line of code: <tt>#import <Foundation/Foundation.h></tt> In fact, if we don't want to have to worry about including the header file for each Foundation class we wish to use in a code file, this is all we need to do. Alternatively, we can selectively include the header files for only the classes we intend to use. For example, the following code imports only the headers we need: <pre>#import <Foundation/NSObject.h>#import <Foundation/NSString.h>#import <Foundation/NSAutoreleasePool.h>int main (int argc, const char * argv[]){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];  NSString *myString = @"Hello";  [pool drain];  return 0;}</pre> == Finding the Foundation Framework Documentation == A detailed overview of every class and method in the Foundation Framework is beyond the scope of this book and would be largely redundant given that this information is already provided by Apple in various locations. Instead, this book will focus on teaching you how to use the most common Foundation classes to work with numbers, strings and file systems. This knowledge, combined with the Apple Foundation documentation should be all you need to be begin working proficiently with these classes.  The Foundation documentation may be accessed either via the Apple web site, or from within the Xcode development environment (accessed via the ''Help->Documentation'' menu option and listed under Foundation Framework Reference). The Framework Reference Documentation lists all the classes available and for each class describes in detail what the class does and what methods are available.

Navigation menu