Delegate in Objective C is used when one class objects wants to assign some of its work to another object.
Example:- in NSTableView we want cell to be drawn as per requirement. So we can delegate that adding data to cell will be done by that another delegate class object.
use of category with delegate
@interface NSObject (NSCommonDelegateMethods)
-...
Tuesday, January 29, 2013
Categories in Objective C
When you want to add something to the existing class normally we go for subclassing.In Objective we can new method to the existing class and the term called as "Category".
Suppose in Circle class u want to add method for converting radius from float to int (let say some extra rounding off). The declaration of category as
.h file
@interface...
Properties in Objective C
Properties is the feature of the Objective C .
It reduces lots of code writing.
Its mainly used for accessor i.e. getting and setting data member. compiler will add that code of getter and setter with respect to the thread safe or not.
syntax
.h file
#import <Foundation/Foundation.h>
@interface Circle : Shape {
int color;
int radius;
}
@property int...
Object Creation and initialization in Objective C
COCO suggest to use alloc and init method for object creation.
alloc:- allocates the required memory for the object and initializes memory content to zero.
init :- will initializes the object data members.
alloc and init should be chaining like this
Rect *rect=[[Rect alloc] init];
should not like
Rect *rect=[Rect alloc];
[rect init];
Reason for...
Monday, January 28, 2013
Memory Management in Objective C
Objective C 2.0 introduces garbage collection to take care of memory.
Reference Counting/Retain counting:-
Every object has an integer with it called reference count or retain count. Which keep count of that object are in use. When you are giving object to some class/ code and used retain when giving then retain/reference count is...
Saturday, January 26, 2013
COCO Foundation Framework in Objective C
This framework mainly consists of classes like NSArray , NSString etc.
Some classe starts with CF they belongs to core foundation . Core foundation is like COCO but implemented in c. Max of its code is open source. eg CFArray.
Classes starts with NS all are part of COCO.
NSValue
It used to allow items of such data types...
Tuesday, January 22, 2013
Useful information for Objective C developer
Use .mm file extension,when your file has C++ and Objective- C code together.
For import and include there is two different ways to include/import file
i.use < > when adding system declared file(system provided file)
ii.use " " when adding local declared file.(declared by you.)
Forward declaration is used when...
Composition OOP
Composition
Composition means consists of many things.Mean Single big object/class consists of many objects in it.
Ex:-
@interface Computer
{
CPU * ptrCpu;
Monitor* ptrMonotor;
Mouse* ptrMouse;
}
@end
Only objects are said to be composed not primitive data type like int ,char etc.
Composition set up "has a...
Tuesday, January 8, 2013
Inheritance OOP concept :
Inheritance:-
Different kinds of objects often have a certain amount in common with each other.
Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.
What is need OR advantages using Inheritance:-
1.You can save code memory, easy to make changes. Suppose theres is function which is common...
Tuesday, January 1, 2013
OOP concept : As Objective C is Object oriented.
OOP(Object oriented programming) is way to construct software which is made of objects(Single or many). Object is like entity which differentiate from other types. eg. Car, Human etc.
In Object oriented programming Data is center point around which function are there this is exactly opposite to procedural programming.
In Objective calling...