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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to