CoreData validation question
CoreData validation question
- Subject: CoreData validation question
- From: Arnold Nefkens <email@hidden>
- Date: Mon, 26 Apr 2010 13:51:55 +0200
Hello list,
I have the following validation method, why is it not working?
-(BOOL)validateNumberField2:(id *)ioValue error:(NSError **)outError
{
NSNumber *inputNumberField2 = *ioValue;
NSNumber *numberField2Stat = self.numberField2;
NSNumber *numberField1Stat = self.numberField1;
if (numberField2Stat != 0) {
if (inputNumberField2 <= numberField1Stat) {
if (outError != NULL) {
NSString *errorStr = NSLocalizedString(@"Error message.",@"Error message");
NSDictionary *userInfoDict = [NSDictionary dictionaryWithObject:errorStr forKey:NSLocalizedDescriptionKey];
NSError *error = [[[NSError alloc] initWithDomain:kValidationDomain code:kValidationnumberField2Code userInfo:userInfoDict] autorelease];
*outError = error;
}
return NO;
}
return YES;
}
return YES;
}
What I want is the following:
The very first object created in CoreData has the initial value of numberField2 = 0.
If you enter a new number for this field it has to be larger then the number in numberField1.
The validation does only work if ,and only if you have already more then 1 object in you CoreData.
What do I have to change in order to make this validation work:
If numberField2 has a value of 0, then return yes, else check if inputNumberField2 is smaller than numberField1. If it is smaller, give validation error, else return yes. I think that the logic of the if statement is sound.
Could someone be so kind and take a look?
Much appreciated
Arnold Nefkens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden