Properties in Objective-C

18 Просмотры
For more videos on technology, visit

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)


@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
Комментариев нет.