Access Specifiers:
The scope of instance variable are limited by access specifiers.
There are 3 access specifiers in Objective c:
1.Protected-The scope of the instance variable is limited to the declared class and also inherited class.
2.Public-No limitation,can be accessed globally.
3.private-The scope of the instance variable is limited only to the class declaring it.
In objective c,default access specifier is Protected.
Property:
Properties are convenient alternatives to write out the access specifiers.To put in simple words-Property is used to define the behaviour of the instance variable.It is used to generate getter & setter methods at run time.properties offer a way to define the information that a class is intended to encapsulate.
We can also add attributes to the property:
1.read,write,readonly,assign,strong,weak,atomic,non-atomic.
Syntax:
@(attributes)Superclass *InstanceVariable;
Synthesize:
It is used to generate getter & setter methods at run time.If a property has been declared in header file it has to synthesised.
Syntax:
@synthesize PropertyName;
Dynamic:
It just tells the compiler that the getter and setter methods are implemented not by the class but somewhere else-like super class or provided at run time.
Syntax:
@dynamic Property name;
The scope of instance variable are limited by access specifiers.
There are 3 access specifiers in Objective c:
1.Protected-The scope of the instance variable is limited to the declared class and also inherited class.
2.Public-No limitation,can be accessed globally.
3.private-The scope of the instance variable is limited only to the class declaring it.
In objective c,default access specifier is Protected.
Property:
Properties are convenient alternatives to write out the access specifiers.To put in simple words-Property is used to define the behaviour of the instance variable.It is used to generate getter & setter methods at run time.properties offer a way to define the information that a class is intended to encapsulate.
We can also add attributes to the property:
1.read,write,readonly,assign,strong,weak,atomic,non-atomic.
Syntax:
@(attributes)Superclass *InstanceVariable;
Synthesize:
It is used to generate getter & setter methods at run time.If a property has been declared in header file it has to synthesised.
Syntax:
@synthesize PropertyName;
Dynamic:
It just tells the compiler that the getter and setter methods are implemented not by the class but somewhere else-like super class or provided at run time.
Syntax:
@dynamic Property name;
Very nice information...thanks for sharing this.....
ReplyDeleteMobile App Development Company
Android app Development Company
ios app development Company
Mobile App Development Companies
iOS interview questions with answer : www.iosiqa.com
ReplyDelete