I use properties pretty much anytime my classes need iVars. For retained properties, I have grown accustomed to a specific way of using the accessor methods to alloc/initialize the actual iVars:
- (void)anInitOrAccessorMethod
{
self.property = [[AClass alloc] init];
[self.property release];
}
Anytime I need to set a non-autoreleased iVar, I use the above style of setting the property (which retains the object), then sending it a release message to offset the alloc+retain. This is in contrast to many community code examples I see, where people just set the iVars directly if the object is created using alloc/create, thus eliminating the extra release.
Besides the extra code overhead, are there any performance drawbacks to my style?
Do not do that. If your property is declared as having
copysemantics, your code will leak the first object and overrelease the second.