A requirement of A.B is that A must declare @synthesize before using the setter or getter
but A->B doesn’t require this.
I don’t understand which is better and what one uses the least amount of memory?
If I convert from A.B to A->B will it use less memory or the same amount?
A->B uses less memory because you don’t need to declare @synthesize, right?
If
ais an Objective-C object thena.b = c;is the same as to write[a setB:c];.setB:in this case is a default name for automatic generated setter method when you are specifying@property (...) typeB b;and@synthesize b. Instead of...you can place corresponding memory specifier, as retain, assign, copy.By writing
a->b = cyou avoid using setter method, and accessbdirectly.So, construction
a->bgenerates less extra-code but breaks one of the major OOP notion of “Encapsulation” and you also should handle memory related staff manually.For example if you’ve specified
retaininb‘s@property, then constructiona.b = cwill behave almost in the same fashion asa->b = [c retain].