• 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: Key value binding to "class" of object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key value binding to "class" of object


  • Subject: Re: Key value binding to "class" of object
  • From: Bill Bumgarner <email@hidden>
  • Date: Thu, 27 Apr 2006 10:55:13 -0700

On Apr 27, 2006, at 10:38 AM, Daniel Jalkut wrote:
In an application I'm working on, it is very useful for me to bind to the class object of a given instance object. I thought I could use a binding with a keypath like:

myObject.class

But this generates a runtime error complaining that the object is not key-value compliant for the key 'class'.

I worked around the problem by defining my own method "objectClass" that simply returns [self class].

Is there some reason why it's a bad idea for the object's class to be exposed as a keyed value, or is this just an oversight?

I don't believe it is an oversight. -class isn't really intended to be used in a KVC context and the runtime is erring on the side of conservative.


I wrote a generic solution for this a while ago:

http://www.friday.com/bbum/2004/01/18/keyvalue-coding-classes/

It allows one to use a path like:

keyValueClassCoding.NSBundle.allFrameworks

It is particularly useful for being able to bind through to various default attributes on things like NSFont or NSColor.

b.bum

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Key value binding to "class" of object
      • From: Daniel Jalkut <email@hidden>
References: 
 >Key value binding to "class" of object (From: Daniel Jalkut <email@hidden>)

  • Prev by Date: First day of the week? Which one?
  • Next by Date: Re: Selector of Open recent document
  • Previous by thread: Key value binding to "class" of object
  • Next by thread: Re: Key value binding to "class" of object
  • Index(es):
    • Date
    • Thread