In a situation where I am assigning an object to an ivar which the object may already be assigned to, is there any benefit to first checking whether it is already assigned to that ivar.
For example, is there any benefit to code A over code B?
A
if (ivar != anObject)
{
ivar = anObject;
}
B
ivar = anObject;
its not strictly necessary, I believe the @property/@synthesize generated setters do this as an optimisation and to stop unneseccary memory management calls on the same object (for a strong property the old object is released and the new one is retained, but if they are the same pointer the end result is the retain count is unchanged)