Sorry if the title is confused but I can't find a way to express my question.
I see many Objective-C example codes and they usually use this:
Clazz *clazz = [[Clazz alloc] init];
self.clazz = clazz;
instead of:
self.clazz = [[Clazz alloc] init];
Does the first approach have any advantage over the second one?
There's no advantage if that's all it does. If the code uses clazz further, then accessing a local variable saves the nanoseconds required to call the self.clazz getter, and avoids the getter entirely which could matter if the getter does anything weird.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With