0

Is there much of a difference between "property" and an "instance variable" in Objective-C?

I have been led to believe that an instance variable that has accessor methods is knows as a "property", but I now I think that this might not be true.

salmanxk
  • 315
  • 5
  • 19

1 Answers1

1

An instance variable is unique to a class. By default, only the class and subclasses can access it. Therefore, as a fundamental principal of object-oriented programming, instance variables (ivars) are private—they are encapsulated by the class.

By contrast, a property is a public value that may or may not correspond to an instance variable. If you want to make an ivar public, you'd probably make a corresponding property.

There is a nice blog to go through. Also, go through the link shared by katleta300 above.

Abhinav
  • 37,684
  • 43
  • 191
  • 309