Why to use @property in iOS app development

165 Views Asked by At

I searched on internet about the @property in iOS and got answers such no need to explicitly use setter and getter method. beside all these answer can u explain me what is exact benefit of using @propert in iOS app development.

what its benefit and when to use?

Thank You.

1

There are 1 best solutions below

0
On

Basics of OOP(Object Oriented Programming) - You hide all ivars / properties to outside world.

@property is specific to Objective-C, which creates ivars and you are given an option either to use compiler defined setter & getter, or create your own by @synthesize.

Few differences still valid for Objective-C and other OOP languages like ivars/properties are private/protected/public. There are ways to set its access-specifiers.

If you are fancied about ivars and properties one of the major advantage is of KVO (Key Value Observer) this helps you to minimize your codes and only self.property name suffice.