The Foundation framework defines a base layer of Objective-C classes.
Why Foundation framework ?
To addition to providing a set of useful primitive object classes, it introduces several paradigms that define functionality not covered by the Objective-C language.
The Foundation framework is designed with these goals in mind:
- Provide a small set of basic utility classes.
- Make software development easier by introducing consistent conventions for things such as deallocation.
- Support Unicode strings, object persistence, and object distribution.
- Provide a level of OS independence to enhance portability.
The framework was developed by NeXTStep, which was acquired by Apple and these foundation classes became part of Mac OS X and iOS.
Since it was developed by NeXTStep, it has class prefix of “NS“.
We have used Foundation Framework in all our sample programs. It is almost a must to use Foundation Framework.
Generally, we use something like #import <Foundation/NSString.h> to import a Objective-C class, but in order avoid importing too many classes, it’s all imported in #import <Foundation/Foundation.h>.
NSObject is the base class of all objects including the foundation kit classes. It provides the methods for memory management. It also provides basic interface to the runtime system and ability to behave as Objective-C objects. It doesn’t have any base class and is the root for all classes.