You are on page 1of 9

OBJECT ORIENTED PROGRAMMING

Objective-C is an object oriented language.


follows ANSI C style coding with methods
There is no formal written standard
Relies mostly on libraries written by others
Flexible almost everything is done at
runtime.
Dynamic Binding
Dynamic Typing
Dynamic Linking

INVENTORS
Objective-C was invented by two men, Brad Cox and
Tom Love.
Both were introduced to Smalltalk at ITT in 1981
Cox thought something like Smalltalk would be very
useful to application developers
Cox modified a C compiler and by 1983 he had a
working Object-oriented extension to C called OOPC.

INVENTORS
Tom Love acquired a commercial copy of Smalltalk-80
while working for Schlumberger Research
With direct access Smalltalk, Love added more to OOPC
making the final product, Objective-C.
In 1986 they release Objective-C through their
company Stepstone

BASIC SYNTAX STRUCTURE


C++ syntax
voidfunction(intx,inty,charz);
Object.function(x,y,z);

Objective-C syntax
(void)function:(int)x,(int)y,
(char)z;
[Objectfunction:x,y,z];

Class Declaration (Interface)


#import<Cocoa/Cocoa.h>
@interfaceNode:NSObject
{
Node*link;
intcontents;
}
+(id)new;
(void)setContent:
(int)number;
(void)setLink:(Node*)next;
(int)getContent;
(Node*)getLink;
@end

Class Definition (Implementation)


#import"node.h
@implementationNode
+(id)new
{return[Nodealloc];}
(void)setContent:(int)number
{contents=number;}
(void)setLink:(Node*)next{
[linkautorelease];
link=[nextretain];
}
(int)getContent
{returncontents;}
(Node*)getLink
{returnlink;}
@end

C++ VS.

Objective-C

Adds OOP,
metaprogramming and
generic programming to
C
Comes with a std
library
Has numerous uses
Large and complex
code for OOP

Only adds OOP to C


Has no standard
library; is dependant
on other libraries
Mostly used for
application building
Simpler way of
handling classes and
objects

Example: main.c
#import"stack.h
intmain(){
Stack*s=[Stacknew];
[spush:1];
[spush:2];
printf("%d\t",[spop]);
[spush:3];
printf("%d\t",[spop]);
printf("%d\t",[spop]);
[srelease];
return0;
}
$ gcc -x objective-c node.m linkList.m stack.m
main.c -framework Cocoa -o stackTest
$./stackTest
2 3 1

we provide online and classroom training for Object oriented


programming

For more details

www.asit.amcsquare.com
Wise Machines India Pvt Ltd
# 360, Sri Sai Padma Arcade,
Varthur Main Road,
Ramagondanahalli,
Whitefield ,Bangalore 560066
9740377262
* we also have branches in Hyderabad and Chennai

You might also like