开发者

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 开发者_StackOverflow中文版out there?


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜