If you use ARC and a recent working environment (recent enough for you to declare your ivars in the @implementation block), the instance variables suddenly become unexpected. What for? Since unlike @properties they belong to the class. There is no risk that they will be accidentally overridden by a subclass.
They are also faster in the simple case, since you do not call any methods to get or set them.
I personally find it cleaner. There are no more class extensions defining private @properties, and all this is undesirable. Just Ivars, beautiful and simple.
Therefore, the best advice, IMHO, is to use them by default. Use @properties only if you really need their functionality, for example:
- You need a way to access them from outside your class.
- You want subclasses to overlap them.
- Your getter or setter is more than just a trivial assignment.
The last two are less common than you think. It is generally not wise to try to override properties in subclasses, simply because it is a bit unusual and there are some rough edges.
If you later find that you need to upgrade ivar to @property, itβs nice and simple - the only place it can be accessed is in your @implementation, so it usually is a simple search and a replacement to add βIβ. to its links (and possibly remove the leading underscore if you name them that way). 'til then you do not need to pay expenses and manage the risks of using @properties.
source share