If when initializing an object that contains a variable:
1) no. this is a bad form for invoking accessories in partially constructed states (e.g. init , dealloc )
2) no. this is a bad form for invoking accessories in partially constructed states (e.g. init , dealloc )
3) right.
Exception: If your ivars are not private and you are subclassing the type declaring the property, then you should also check if the parent class has initialized the property. it is best to make properties private or not directly accessible to subclasses.
4) no. this is a bad form for invoking accessories in partially constructed states (e.g. init , dealloc )
When you are working with a fully constructed instance:
1), this is normal if readbaility is more important than keeping heap sizes low.
2) bad. the object returned from the receiver is not necessarily the object that you assigned.
3) Bad. leakage may occur if _myProperty not nil .
4) best
justin
source share