Corporation it was designed to enable power full feature of objective oriented programming it works as a power full set of extension to the c-language.
Objective c has same additional keywords to avoid conflict with keyword in other languages it uses @ at the being of the key words
Exception handling directives:
Directives used for particular purpose:
Keywords for memory management:
some other keywords:
Pre processor directives:
A class is nothing but a collection of variables and function it is a blue print for creating objects
Note:- NS object is main base class for all objects
@interface a: other class name <protocol1, protocol2, protocol3>
@property (non atomic , retain)nesting*str”;
Void addition ();
Void addition ()
Void subtraction ()
objective c 2.0 introduce a new syn tax to declare instance variable as properties.
In objective c by default property attribute is atomic in atomic multiple threads are created for setting and getting the values for creating thread extra code will be generated and it leads to performance issue
By using this attribute we tell the compiler that it doesn’t to generate extra code for thread creation. It is a thread safety.
If we doesn’t specify non-atomic the compiler will generate extra code, and property can accessed from single threads with improves to performance.
This attribute tells the compiler that the property can declare be read but not be said the compiler will be only generate.
This is specifies that you are instead in putting ownership claim on the object if the caller releases this object it does not deal located because you retained.
This attribute creates copy of the object can we called setter method, and then you become owner of the new object.
1) Setter methods: This is use per setting a value to the property
2) Getter method: This is used per getting a value to the property
3) @synthesize: If you use this directive in a program for property then no need to write accessory methods to the property.
Syntax:- @synthesize str;
Realizing a property:
Syntax:- [str release];
These statements written in deal loc method.
Subroutines are generally called methods in objective c they are divided in to 2 types
1. Class methods
2. Instance methods
→ A class method is noted with a + in declaration and documentation.
→ An instance method is marked with in (-) sign
→ Every method can be called by class or instance of the class
Syntax of objective C methods:
+ (return type) method name———–instant class method
_ (return type)method name————instance method.
#import <UIKIT/UIKIT .h>
@interface auto view controller . UI view controller
– (void) addition;
– (void) subtraction : (int)a b : (int)b;
+ (void) divisions;
+ (void) multiplication;
#import “auto view Controller.h”
@implementation auto view controller
– (void) addition
//calling instance method
[Self Subtraction: 10 B: 20]
//Calling Class method
[Auto view controller division];
– (void) subtraction: (int)a b:int)b
+ (void) division
àHow to print an message in the command prompt
NSLog(@”type message in here”);
àHow to print objects in the command prompt
printf (“%d %f”, a, b);
NSLog (@”%d%@”,a, any object);
#import <foundation / foundation .h>
@ Interface NS object (algebra)
– (void) addition;
#import NS object + algebra .h”
@implementation NS object(algebra)
→ Unlike subclass category can’t add instance method.
→ You can however use category to over side existing methods in sub classes.
Note: When we make changes a class using a category it affects all instances of that class throughout the application.
Id: Id is a generally type assigning any type of object regards less of class by default all c functions return integer type in objective c it returns id type
NS string *str = @ “Hai”; // str is string object
Id str = str;
// id as return type
Return some obj;
// id as argument
– (void)addition;(id)str bLid)str2
It difference between function call’s and messages is that in a function call which are arguments are join to gather on the compilation code but in case of messages not link until program is run [ linking and runtime]
Ex:- void view did load
Binding on run time so this is calling as dynamic binding it
It is a not a compile time error
The extra method that is involved to respond a message can only determined at runtime.
Enroll for Instructor Led Live IOS DEVELOPMENT TRAINING
Get Updates on Tech posts, Interview & Certification questions and training schedules