• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Properties and the runtime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properties and the runtime


  • Subject: Re: Properties and the runtime
  • From: Michael Ash <email@hidden>
  • Date: Mon, 30 Mar 2009 11:57:31 -0400

On Mon, Mar 30, 2009 at 1:06 AM, Luke the Hiesterman <email@hidden> 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 (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

References: 
 >Properties and the runtime (From: Luke the Hiesterman <email@hidden>)

  • Prev by Date: Re: Delayed Undo Problem
  • Next by Date: Best Strategy to Control iTunes
  • Previous by thread: Re: Properties and the runtime
  • Next by thread: Decode a base64 image for iphone
  • Index(es):
    • Date
    • Thread