• 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
Key-Value Coding Limitations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Key-Value Coding Limitations


  • Subject: Key-Value Coding Limitations
  • From: Jonathon Mah <email@hidden>
  • Date: Sat, 6 May 2006 00:51:09 +0930

Hi all,

It seems I've come across a bug in key-value coding with direct instance variable access. With a class such as:

File: MyClass.mm

// Objective-C++ class
@interface MyClass : NSObject
{
    NSObject *obj;
    NSRect *rectPtr;
    cppObject *cplus;
}
@end

Sending [self valueForKey:@"obj"] works as expected, but [self valueForKey:@"rectPtr"] and @"cplus" raises an NSUndefinedKeyException. Running class-dump shows C++ pointer objects are converted to struct cppObject *cplus. It strikes me as strange, since it's just another pointer; I can even change NSRect* to id, and it will work as expected. void* raises the exception. Is this a known limitation of struct/void pointers?

Is there an easy way to access arbitrary instance variables by name, or must I manually go through the Objective-C class structures?

The reason I want this is for a plug-in I've created which uses class posing. It requires access to some instance variables that don't have accessor methods, and accessing them "normally" in my code makes it more likely to break under future/past versions.


Thanks,


Jonathon Mah email@hidden


_______________________________________________ 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 Coding Limitations
      • From: James Bucanek <email@hidden>
  • Prev by Date: Re: autorelease question
  • Next by Date: How to control the commit of text edit field with binding?
  • Previous by thread: Bindings, searchfield, how to use predicate to search related database
  • Next by thread: Re: Key-Value Coding Limitations
  • Index(es):
    • Date
    • Thread