Thanks for that information - that’s very helpful. It sounds from what you are 
saying as if there is nothing wrong with me redefining the *property* in the 
subclass (as read-write), but that it’s just the synthesis itself that is the 
problem? Assuming that is the case, I can easily(*) rectify that by writing 
explicit setters/getters, so I will do that.

(*) there are rather a lot of these properties in the actual original code, but 
it just involves a lot of typing!


On 5 Jul 2016, at 16:12, Keary Suska <cocoa-...@esoteritech.com> wrote:

> 
>> On Jul 5, 2016, at 5:36 AM, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
>> wrote:
>> 
>> I have a problem with property synthesis in my code, which I hope somebody 
>> can advise on. I find I have to write different property synthesis code for 
>> 32- or 64-bit builds in order to avoid compiler errors.
>> 
>> A minimal demonstration of the problem can be found below - build as part of 
>> a fresh project on Xcode 5 or 6, with ARC disabled. It surprises me that I 
>> have to write different synthesis code for 32- or 64-bit builds - and this 
>> then makes me worry that I am doing something more fundamentally wrong. Can 
>> anyone comment (or explain)?
>> 
>> [I appreciate that this code may be old-fashioned in style - I am not even 
>> sure what is or is not the recommended style these days. It seems to work 
>> though - and, importantly, as far as I can tell the synthesized property 
>> myFlag on MutableSettings *does* map to the same backing variable, even on a 
>> 64-bit build where I am not able to specify the backing variable in the 
>> synthesis statement]
> 
> 32 vs 64 is likely coincidental, and probably has more to do with compiler 
> differences. I.e., at that time, there were additional compiler “features” 
> for 64 bit vs 32 bit. So my thought is that what you are doing is wrong in 
> both cases, but you are simply getting different compiler errors.
> 
> The essential issue I believe is that you cannot re-synthesize in a subclass. 
> You will have to specify the setter explicitly. The issue in the second 
> (64-bit) case is that when you specify @synthesize with an instance variable 
> you are specifying a *new* instance variable on that class, but the compiler 
> correctly warns you that that instance variable has already been defined in 
> the superclass and therefore cannot also be defined in the subclass. The 32 
> bit compiler seems to be letting you get away with this error, but it could 
> have horrible unintended consequences.

_______________________________________________

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