Key-Value Coding default accessor search implementation
Key-Value Coding default accessor search implementation
- Subject: Key-Value Coding default accessor search implementation
- From: Francis Derive <email@hidden>
- Date: Fri, 18 Nov 2005 15:23:21 +0100
Hello,
Exercising on this subject, I get an error when I substitute
"myInstance" with "ismyInstance".
It is fine with "_myInstance".
// kvc.h
@interface MYobject : NSObject {
//NSString *myInstance; Fine
//NSString *_myInstance; Fine
NSString *ismyInstance;
}
//- (NSString *) myInstance;
//- (void) setmyInstance:(NSString *) anInstance;
@end
// kvc.m
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "MYobject.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
MYobject *unObjet = [[MYobject alloc] init];
NSLog(@" what about accessInstanceVariablesDirectly %d", [MYobject
accessInstanceVariablesDirectly] ? 1 : 0);
NSLog(@" lecture par kvc valueForKey: -- %@", [unObjet
valueForKey:@"myInstance"]);
[unObjet setValue:@"myInstance with kvc" forKey:@"myInstance"];
NSLog(@" lecture par kvc valueForKey: -- %@", [unObjet
valueForKey:@"myInstance"]);
// insert code here...
NSLog(@"Hello, World!");
[pool release];
return 0;
}
[Session started at 2005-11-18 15:17:26 +0100.]
2005-11-18 15:17:27.234 KVC[1868] what about
accessInstanceVariablesDirectly 1
2005-11-18 15:17:27.304 KVC[1868] *** Uncaught exception:
<NSUnknownKeyException> [<MYobject 0x303d80> valueForUndefinedKey:]:
this class is not key value coding-compliant for the key myInstance.
KVC has exited due to signal 5 (SIGTRAP).
_______________________________________________
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