Possible Duplicate:
Why is my object not key value coding-compliant?
I’m having a dictionary and I want to add keys/values to a custom class, but i always get the error, that the class is not KVC compliant, but the Apple documents state that it should be.
My code:
ContactObject.h:
@interface ContactObject : NSObject
+ (ContactObject *)testAdding;
@end
ContactObject.m:
@implementation ContactObject
- (id)init {
self = [super init];
if (self) {
// customize
}
return self;
}
+ (ContactObject *)testAdding
{
// create object
ContactObject *theReturnObject = [[ContactObject alloc] init];
[theReturnObject setValue:@"Berlin" forKey:@"city"];
[theReturnObject setValue:@"Germany" forKey:@"state"];
return theReturnObject;
}
@end
I think I’m missing something very stupid 🙂
Please, any help appreciated …
Greetings,
matthias
Actually to be KVC compliant:
key.setKey:. (If the property is aBooleanattribute, the getter accessor method has the formisKey.)keyor_key.I don’t see any of these three implemented. You need to have at least properties that you are trying to set through KVC, the default NSObject implementation is able to set properties through
setValue:forKey:but you must declare them.