• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData validation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: CoreData validation question
      • From: Steve Bird <email@hidden>
  • Prev by Date: Re: Creating temporary NSManagedObjects
  • Next by Date: Re: CoreData validation question
  • Previous by thread: Re: Creating temporary NSManagedObjects
  • Next by thread: Re: CoreData validation question
  • Index(es):
    • Date
    • Thread