• 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
DO bycopy qualifier and Key-Value Coding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DO bycopy qualifier and Key-Value Coding


  • Subject: DO bycopy qualifier and Key-Value Coding
  • From: Petteri Kamppuri <email@hidden>
  • Date: Fri, 12 Jan 2007 15:43:11 +0200

Hi!

I ran into a strange problem with classes having accessor methods using Distributed Objects bycopy method qualifiers and Key-Value Coding.

This can be demonstrated with this simple example class:

@interface MyObject : NSObject
{

}

-(bycopy NSString *) name;

@end


@implementation MyObject

-(bycopy NSString *) name
{
    return @"The name";
}

@end



Using the name through KVC like this results in an exception being thrown.

NSMutableArray *array = [NSMutableArray arrayWithObjects:[[[MyObject alloc] init] autorelease], [[[MyObject alloc] init] autorelease], [[[MyObject alloc] init] autorelease], nil]; // Just create a few objects

[array sortUsingDescriptors:[NSArray arrayWithObject: [[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease]]]; // Sort using KVC



Output:

Exception raised during posting of notification. Ignored. exception: [<MyObject 0x34a8c0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key name.


I can fix this in valueForUndefinedKey: by checking the key and returning [self name] when the key is @"name", but IMHO that shouldn't be needed. This should just work.


Rremoving the bycopy qualifier will fix the error. So it's the qualifiers fault.

Is this by design or should I file a bug report? Or are there some other things involved?


Thanks for any help,

Petteri Kamppuri
email@hidden
Senior Cocoa Engineer, MK&C
http://www.karppinen.fi/


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Re: View NSImageView for few milliseconds and hide.
  • Next by Date: Re: Opening an NSWindow programatically
  • Previous by thread: Re: View NSImageView for few milliseconds and hide.
  • Next by thread: NSTableColumn "enabled" binding on 10.3.9
  • Index(es):
    • Date
    • Thread