> On 21 May 2015, at 6:50 am, Michael David Crawford <mdcrawf...@gmail.com> 
> wrote:
> 
> In my own code I started with nothing but ivars, but changed some of
> them to properties while neglecting to remove the original ivar.  This
> leaves me somewhat in the same situation as you.


Nothing wrong with that, AS LONG as you remember to add the @synthesize foo = 
myOriginalIvar in your implementation. Problem is, it’s not a compile-time 
error if you forget. It might not even be a runtime error, but it’s very likely 
a bug anyway, because when you think you’re manipulating < myOriginalIvar >, in 
fact it’s manipulating a hidden _foo ivar. At its most benign, this is just a 
minor waste of space for the < myOriginalIvar > storage, but if code (and 
legacy code is quite likely to do this) is sometimes accessing the ivar 
directly, and sometimes through the property, you have a very, very definite 
and insidious bug.

Frankly, (and I have said this before more than once) the design of 
autosynthesizing properties, added as it was later to properties themselves, is 
a nasty way to shoot yourself in the foot and not even realise it. Caught me 
out numerous times.

You can enable the warning CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS 
(“Implicit Synthesized Properties” in build settings) to at least be told when 
you pulled the trigger.

—Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to