I am pretty new to iPhone development and I am getting this error output. I know what is happening, I just don't know how to fix it.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<loginData 0x6b1c> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key UserEMailAddress.'
Basically I am using the XML parser and trying to store data into my created class 'loginData.' The first element I come to, is UserEMailAddress and the code is trying to store that value into the class variable UserEMailAddress of the same name. But its throwing that error.
Obviously something went awry when I created my class. Somehow I guess things were not set up right and it can't input the data into the class. All I did to create loginData was do a file->new-> class object.
Here is the class code.
loginData.h
#import <Foundation/Foundation.h>
@interface loginData : NSObject{
NSString *UserEMailAddress;
NSString *SessionUID;
NSString *SessionExpirationUTCDT;
}
@property (nonatomic, retain) NSString *UserEMailAddress;
@property (nonatomic, retain) NSString *SessionUID;
@property (nonatomic, retain) NSString *SessionExpirationUTCDT;
@end
loginData.m
#import "loginData.h"
@implementation loginData
@synthesize UserEMailAddress=_UserEMailAddress;
@synthesize SessionUID=_SessionUID;
@synthesize SessionExpirationUTCDT=_SessionExpirationUTCDT;
@end
pretty simple stuff, nothing too complex.
the last method accessed before the crash is in my XMLParser, which is..
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if (!currentElementValue) {
// init the ad hoc string with the value
currentElementValue = [[NSMutableString alloc] initWithString:string];
} else {
// append value to the ad hoc string
[currentElementValue appendString:string];
}
NSLog(@"Processing value for : %@", string);
}
I'm sure I just made a small mistake in making my class, but I don't know what that would be. Thanks in advance.
The only other method where it looks as if the variables are input to my class is this one.
- (void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"LoginResponse"]) {
// We reached the end of the XML document
return;
}
//if ([elementName isEqualToString:@"user"]) {
// We are done with user entry – add the parsed user
// object to our user array
//[users addObject:user];
// release user object
//[user release];
//user = nil;
// }
else {
// The parser hit one of the element values.
// This syntax is possible because User object
// property names match the XML user element names
[loginData setValue:currentElementValue forKey:elementName];
}
currentElementValue = nil;
}