-1

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.

Nasir
  • 1,617
  • 2
  • 19
  • 34

1 Answers1

0

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.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140