Re: Synthesised properties and additional actions
Re: Synthesised properties and additional actions
- Subject: Re: Synthesised properties and additional actions
- From: Matt Neuburg <email@hidden>
- Date: Wed, 22 Jun 2011 08:45:44 -0700
On Wed, 22 Jun 2011 09:23:54 +0100, Joanna Carter <email@hidden> said:
>Hi folks
>
>Le 22 juin 2011 à 08:58, Ken Tozier a écrit :
>
>> I just started using @properties this week, so probably don't understand the nuances, but after looking at Matt's sample code, reading the property related docs and doing some experimentation, I'm not sure I understand what problem he's trying to solve. Is he talking about overriding inherited getters/setters?
>>
>> With my own very limited experience with properties, it seems to be really easy to add functionality. Just write the getter/setter yourself. When you go to use them, they behave exactly like the auto generated ones re dot syntax, and do whatever cool thing you added.
>>
>> What am I missing?
>
>Yes, I would also like to know what Matt is trying to achieve with all those machinations that you can't do with a simple ivar in the class and not bothering to @synthesize.
Well, if you really want to know that, just read the discussion in the book:
http://www.apeth.com/iOSBook/ch12.html
My thought was (putting myself in the shoes of the student), hey, I have no idea exactly what code @synthesize generates, but whatever it is, it surely constitutes a correct getter and (especially) setter, whereas if I write those things myself (and especially the setter) the chances that I'll do something wrong are quite high. So the question is simply, how can I add my own functionality while at the same time inheriting all the synthesized accessors' yummy goodness, whatever it may be? m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
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