I am parsing XML that gets returned from a web service. If it is a valid user than I should be getting a long integer back. (for example: 2110504192344912815 or 2061128143657912001). If it is invalid then I get a 0. However if you see my code, I am getting negative values sometimes for userID and that is throwing my validation code hay wire. Any tips?
NSMutableString *loginString;
NSInteger userID;
-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *) elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{
if ([elementName isEqual:@"GetUIDResult"]) {
userID = [loginString longLongValue]; / 0 if invalid password or LONG
[loginString release];
loginString = nil;
}
}
//MY VALIDATION CODE..
NSLog(@"The value of userID is: %ld",userID);
if (userID > 0) {
NSLog(@"YOU ARE NOW LOGGED IN");
}else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Validation Error" message:@"Unable to validate Login/Password combination" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}