All IT Courses 50% Off
QA Tutorials

Objective C Programming 

Objective C is well known general purpose language which is developed on top of C Programming language by adding the features of small talk programming by making it an object oriented language. It will be primarily used as the developing iOS and Mac OS X operating system and well known applications.

Object-Oriented Programming

Objective-C will is fully supported by object oriented programming, includes the four pillars of object oriented development:

  • Encapsulation
  • Data hiding
  • Inheritance
  • Polymorphism

For example

#import <Foundation/Foundation.h>

All IT Courses 50% Off

void main (int argc11, const char * argv[]) {

   NSAutoreleasePool1 * poo1l = [[NSAutoreleasePool1 alloc] init];

   NSLog (@”hi world”);

   [pool drain];

}

Foundation Framework:

Foundation Framework will provide a large set of features which are listed as:

  • It will include a list of extended datatypes like NSArray, NSDictionary, NSSet.
  • It has rich set of functions manipulating files and strings etc.
  • It provides many features for URL handling,utilities like data formatting, data handling or error handling.

Learning objective C

The very important task to do when learning objective C, is to focus on the concepts and not get lost in any of the technical details. The main objective of learning a programming language is to become a better programmer more effective in designing and implementing new systems are at maintaining the old ones.

Use of Objective C

Objective C is mentioned as earlier that is used in an iOS and also MAC OS X. It has large base of iOS users and largely increasing Mac Os x users and since Apple focuses on quality first and its wonderful for those who will start learning objective-C.

The environment setup

We can also install Text Editor and the GCC compiler on the computer. 

Text Editor

This is a type of program. Examples of few editors that include windows notepad, OS Edit command, Brief and Vim or may be vi.

The text editor’s name and version is different for different operating system. Consider an example notepad will be used for windows and vim or vi used on linux and unix. The files where we can create with our editor are called source files and contain program source code. The source files for objective-C programs are typically named with extension “.m”

Before starting our programming make sure that we have one text editor in place and we have enough experience to write the computer program, save it in file, compile it ,finally execute it.

The GCC compiler:

This source code is coded in a source file can compile to turn into human readable form a program. It requires to be “compiled” to turn the machine language so that your CPU can actually execute the code the program as per the program per instruction. The GCC compiler will be used to compile the source code into the final executable program where the basic knowledge about the programming language compiler.

The GCC compiler is used to compile your source code into final executable program. It is available for free on various platforms and the procedure to set up on various platforms explained as

Installation on Windows

To execute the objective C program on windows we need to install MinGW and GNUstep core. Both will be available at https://www.gnu.org/.

We have to install the MYSYS/MinGW system package. Then we need to install the GNU step core package. Both of which are provided a windows installer, which is self explanatory.

Then use of objective-C and also GNU step by selecting start->All Programs->GNUstep->Shell

We have to switch folder containing Hi world

We can compile the program

$ gcc `gnustep-config –objc-flags` 

-L /GNUstep/System/Library/Libraries hello.m -o hello -lgnustep-base -lobjc

we can run the program by using

./Hi.exe

we will get the output as

2022-09-01 10:48:39.772 iitworkforceA[1200] Hi world

Installation on UNIX or Linux

This is the first step to install the GCC compiler along with GCC objective C package.

$ su – 

$ yum install gcc

$ yum install gcc-objc

The next step will be to set the package dependencies using the following command

$ yum install make libpng libpng-level libtiff libtiff-level libobjc 

   libxml2 libxml2-devel libX11-devel libXt-devel libjpeg libjpeg-devel

To get the full features we have install GNU step by http://gnu.org/ and we have to unpack the file by

$ tar xvfz gnustep-startup-.tar.gz.

Then  switch folder where gnustep-startup that gets created

$ cd gnustep-startup-<version>

then build and configure

$ ./configure

$ make

And set up the environment by

$ . /usr/GNUstep/System/Library/Makefiles/GNUstep.sh

Questions

1. What is C objective?

2. Explain the features of C objective?

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles

Back to top button