r/ObjectiveC • u/itsfeykro • Jun 29 '22
Is there a difference between [self attributeName] and self.attributeName ?
Hello,
I'm an objective-C newbie, and I've got to work on some legacy code. A question I can't find a clear answer to is the difference between `[self attributeName]` and `self.name.`
So I declare a .h for a class, its attributes and methods and I want to interact with them in the .m. I usually feel more comfortable using `self.name` for assigning a value to the class's attribute and `[self attributeName]` for reading the value of the attribute, but I feel like they're totally interchangeable.
Am I correct or is there a real difference I'm missing ?
Thanks in advance !
View all comments
Show parent comment
5
u/itsfeykro Jun 29 '22
I’m not sure what to take away from this, especially since it lacks examples of any kind. I’ve been writing getter functions like you would in java :
Should I not have? Is [ self isActivated ] already an implicit getter?