I know that properties kind of encapsulate getter and setter methods. So whenever we say myObject.property1 we actually cause to call [myObject property1]. From Apple documentation, Stanford iOS Courses and sample codes I can see that the usage of properties are encouraged. I aggree that using properties make a code look better and more understandable but what about performance? If I write a huge application will using properties have a noticableimpact on performance? Do professionals generally prefer direct setter and getter methods or properties?
There is no difference in performance when you use the bracket notation ([myObject property1]
) or the .
notation (myObject.property1
).
This is more of a coding style than any thing else, so use the notation you are comfortable with or the same notation as your team if you don't work alone.
Properties are probably better because they automatically generate the methods for you and when you synthesize them you can do it like this:
@synthesize property = _property
To avoid any confusion
Also you can choose different functions/methods like:
(nonatomic, retain) // or (readonly) etc.
It also handles the memory better
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