Question

If an ivar is to be used globally within the class, but will never be accessed by other classes, are we still supposed to use properties?

Was it helpful?

Solution

It is generally a good idea, as the generated accessors will take care of things like memory management and KVO for you. You can put the property in a class extension so other classes can't use it.

OTHER TIPS

For me, it depends on what the instance variable will be used for.

If it's an object representing some data, then I will always use a property.

If it's just a simple BOOL for some internal bookkeeping by a couple of methods in the class, then I won't create a property for it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top