Obj-C Foundation Framework



If you refer Apple documentation, you can see the details of Foundation framework as given below.

The Foundation framework defines a base layer of Objective-C classes. In 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 de-allocation.

  • 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. As 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.

Foundation Classes based on functionality

Sr.No. Loop Type & Description
1 Data storage

NSArray, NSDictionary, and NSSet provide storage for Objective-C objects of any class.

2 Text and strings

NSCharacterSet represents various groupings of characters that are used by the NSString and NSScanner classes. The NSString classes represent text strings and provide methods for searching, combining, and comparing strings. An NSScanner object is used to scan numbers and words from an NSString object.

3 Dates and times

The NSDate, NSTimeZone, and NSCalendar classes store times and dates and represent calendrical information. They offer methods for calculating date and time differences. Together with NSLocale, they provide methods for displaying dates and times in many formats and for adjusting times and dates based on location in the world.

4 Exception handling

Exception handling is used to handle unexpected situations and it's offered in Objective-C with NSException.

5 File handling

File handling is done with the help of class NSFileManager.

6 URL loading system

A set of classes and protocols that provide access to common Internet protocols.

Advertisements