Subject: Re: Properties and the runtime
On Mon, Mar 30, 2009 at 1:06 AM, Luke the Hiesterman <luketheh@xxxxxxxxx> wrote:
> Up to this point, I've thought of properties as "syntactic sugar" for method
> calls. That is myObject.size should compile the same as [myObject size]
> unless of course a custom getter is set in the property declaration, then it
> would compile the same as if I had called that getter. What makes me
> question this is that there's apparently a need for dealing with properties
> at the runtime level, as discussed in
> I can't think of anything about properties that needs to be dealt with at
> runtime. My understanding has it that all information necessary for what
> properties do is available at compile time. E.g. the method to call, return
> types, how to compile synthesized properties using copy, retain, assign,
> nonatomic, and also whether to throw an error if something is readonly. So,
> then, my question is, what about using properties requires a runtime
> component? To me it feels like everything could be handled by the compiler.
I think what you're missing is that the runtime has a lot of
information available through APIs that aren't strictly necessary at
runtime. For example, you can get a list of method names and
argument/return types, or a list of ivar names and types, even though
none of this stuff is needed to send a message or access an ivar.
This sort of metadata is provided just for the benefit of other code.
For example, the method/ivar information is used by Cocoa to implement
things like key/v...
alue coding. You can use it yourself for your own
purposes. As far as I know, Cocoa doesn't use the property info for
anything at the moment, but it's there just so that you can use it if
you have a use for it.
And one last note: don't mix up the dot syntax with properties. The
API whose documentation you've linked to is about @property stuff. The
dot syntax is just a funny way to message getters and setters. Other
than the fact that the dot syntax is commonly used with getters and
setters declared with @property, they are completely unrelated.
Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)
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 maillists@xxxxxxxxx