dontWatchMyProfile
dontWatchMyProfile

Reputation: 46360

Is there an tutorial that shows how attribute validation works in Core Data?

I'd like to play around with attribute value validation, but the documentation is pretty empty on this. Maybe there's an good article or tutorial out there?

Upvotes: 0

Views: 110

Answers (1)

TechZen
TechZen

Reputation: 64428

Here is a fairly common validation to ensure you don't get nonsensical dates put into a timeStamp.

- (BOOL)validateTimeStamp:(id *)valueRef error:(NSError **)outError 
{
    NSDate *testDate=(NSDate *) valueRef;
    if ([testDate compare:self.minimumTimeStamp]==NSOrderedAscending) {
        // generate and return error so you can set a proper date
    }
    return YES;
}

Upvotes: 1

Related Questions