On Mon, Mar 30, 2009 at 1:06 AM, Luke the Hiesterman <luket...@apple.com> 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
> http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html
>
> 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/value 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.

Mike
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to