Properties in Objective-C

18 Просмотры
Издатель
For more videos on technology, visit http://www.Techytube.com

By Pavel@Techytube

Properties in Objective-C are some specific syntax commonly used in
this language.

Instead of declaring 2 methods (a getter and a setter) for each
variable or object declared inside our class, we can declare a
property that does that automatically for us.

We declare a property inside the interface file (after the closing "}"
), with the following syntax:

@property (nonatomic, strong) ClassName *propertyName; (for objects)

and

@property (nonatomic, strong) DataType propertyName; (for variables)

Then, in the implementation file, after the "@implementation
ClassName" line, we have to write:

@synthesize propertyName = _ propertyName;
, which will create the getter and setter on our behalf.
Категория
Разработка на iOS Язык программирования Objective-C
Комментариев нет.