Objective C : Programming Language

Introduction:

Objective C is a general purpose, high level, object oriented programming language. It is the primary programming language for developing Mac OSX or iOS application. It’s a superset of the C programming language and provides object-oriented capabilities. Objective-C inherits the basic features like primitive types, flow control, pointers, structures etc from C and adds syntax for defining classes and methods.

History:

Brad Cox and Tom Love modified C programming language and created Objective C for their own company named Stepstone in 1983. In 1986, Cox published description of Objective-C in the book Object-Oriented Programming, An Evolutionary Approach.

In 1988, NeXT got the license from StepStone for Objective-C and started developing it. NextStep created AppKit and FoundationKit libraries on which the user interface and Interface Builder were based. NextStep bought full rights from Stepstone in 1995 and NextStep was acquired by Apple in 1997, so Objective-C become proprietary software for Apple.

Mac OS was redesigned using Objective-C and its GUI components were developed and named as Cocoa. Cocoa was further redesigned for iOS (iPhone) and named as Cocoa Touch. This way Objective-C becomes major programming language for Apple products.

Getting Started:

Since Objective-C is primarily used on Apple platform like Mac OSX desktop applications, iOS application, watchOS, tvOS etc, so we will focus our tutorial in line with Xcode editor and MacOSX application development environment.

Xcode installation:

You can get Xcode from Apple's App Store.

  1. Launch App Store
  2. Search for Xcode on App Store
  3. Install Xcode



Xcode installation is very easy. App Store app does everything itself once you click on install button next to Xcode icon as shown in above screenshot. You might have to authenticate your download against your App Store credentials.

First Objective C Program: "Hello World"

Launch Xcode on your mac.

Create new Xcode project.


Select command line project in MacOS X environment as shown in this pic.

Select the programming language as Objective-C and provide your "Product Name". Lets give Product Name as "HelloWorld" as shown in screenshot. Then go ahead and save the project on your mac [may be in Document folder or on Desktop].

On completion of last step, you will see there are some files created for you and in left column which is project navigator the files are listed. Click on main.m and you will see some code pre-written for you. At this point you are actually done with your first project "HelloWorld", the wizard has created it everything for you and now you have to Run the App to see the output.

See the output in console as shown in below screenshot.