문제

I have the following classes declared in my iOS application...

@interface UserRegistrationRequest : BaseServiceRequest

@property (nonatomic, retain) NSString *username;
@property (nonatomic, retain) NSString *password;
@property (nonatomic, retain) NSString *secretQuestionID;
@property (nonatomic, retain) NSString *secretQuestionAnswer;
@property (nonatomic, retain) UserProfile *profile;

@end


@interface UserProfile : NSObject

@property (nonatomic, retain) NSString *emailAddress;
@property (nonatomic, retain) NSString *firstName;
@property (nonatomic, retain) NSString *lastName;
@property (nonatomic, retain) NSData *profileImage;
@property (nonatomic, retain) NSNumber *dateOfBirth;

@end

As best as I can tell, these classes should be key-value coding compliant. However, when I run the following code...

NSString *propKey = @"profile.firstName";
NSString *propVal = [self.registrationRequest valueForKey:propKey];

I get an exception saying...

[<UserRegistrationRequest 0xb6187f0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key profile.firstName.

Any idea why this is happening or what I should be looking for in troubleshooting this?

도움이 되었습니까?

해결책

Use :

NSString *propVal = [self.registrationRequest valueForKeyPath:propKey];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top