Objective C Tutorial - Objective-C Tutorial






Objective-C is an object-oriented programming language.

It is the main programming language used by Apple for the OS X and iOS operating systems and their respective APIs, Cocoa and Cocoa Touch.

Example Code

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   NSLog (@"hello world");
   [pool drain];
   return 0;
}




Foundation Framework

The following line in the code above include the foundation framework into our code.

#import <Foundation/Foundation.h>

Foundation Framework has libraries and features we can use.

It includes a list of extended datatypes like NSArray, NSDictionary, NSSet and so on.

Foundation Framework has a set of functions we can use to manipulate files, strings, etc.

We can also use Foundation Framework to do URL handling, date formatting, data handling, error handling, etc.

File name extension

Objective-C source files use .m as extension.

The following table lists other commonly used filename extensions.

ExtensionMeaning
.cC language source file
.cc, .cppC++ language source file
.hHeader file
.mObjective-C source file
.mmObjective-C++ source file
.oObject (compiled) file