Re: Disabling auto-synthesis of property accessors.
Re: Disabling auto-synthesis of property accessors.
- Subject: Re: Disabling auto-synthesis of property accessors.
- From: Uli Kusterer <email@hidden>
- Date: Fri, 22 May 2015 09:43:55 +0200
On 21 May 2015, at 19:55, Quincey Morris <email@hidden> wrote:
> On May 21, 2015, at 10:40 , Fritz Anderson <email@hidden> wrote:
>>
>> I must have misinterpreted the question. I had understood Alex wanted a build option to turn off the auto-synthesis of properties, so the compiler could complain at every conflation of ivars with @propertys.
>
> You didn’t misinterpret the question, but there’s no such build setting, so you have to solve the problem indirectly.
>
> — You turn on the @synthesize warning.
>
> — The warning message tells you when you’ve omitted a @synthesize.
>
> — You add the “new-style” @synthesize:
>
> @synthesize myProperty = _myProperty;
>
> — Then all of your old naked ‘myProperty’ ivar references produce compile errors. QED.
>
> Changing an old-style ‘@synthesize myProperty;’ to the new style leads to a similar result, but there’s no initial warning message to lead you there by the hand.
That seems pointless, as auto-synthesis already names the backing ivar it creates _myProperty. Looking at the original thread "Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?” that spawned this, just deleting all the ivar declarations and @synthesize directives might be a better idea, then direct ivar accesses don’t find anything named myProperty and will error out directly. Or synthesize all properties with a name nobody is using yet for the backing ivar, if you have some that use _foo, or mFoo and others that just use foo.
Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden