There is no difference here :
UILabel * l = [self lbl]; // == UILablel *l = self.lbl;
[self setLbl:l]; // == self.lbl = l;
但是,你们的样本有不同之处:
_lbl.text = @"A";
That last one is not good because you are accessing the iVar directly bypassing your @property, which often don t make sense to do if you have declare it as @property
.
In your case you are changing a property on your iVar, so there is no harm, but if you would do this :
_lbl = [[[UILabel alloc] initWithFrame:aRect] autorelease];
that would cause you a big problem, because you would have bypass the "setter". A strong
setter would have retain that object, but now it s retain by no one, it will go away and you will have a bad pointer, that can make your application crash.