开发者

Validation not automatically called except when using KVC key-value-coding access

I implemented a KVC validation method that is called by coredata, but is not being called when I call person.name = @"alice";

is there a reason why KVC validation methods, in this case,


- (BOOL)validateName:(id *)ioValue error:(NSError **)outError {
    NSLog(@"validateName is validating...");    
    // ...    
}

is not being called when setting a value via property expression?

Another problem is that I can't get this to work either:


[person setValue:@"ok" 开发者_StackOverflowforKey:@"name"];

My NSLog line NEVER gets called.

Anything I'm missing?

This class is a subclass of NSManagedObject.

Does that matter?

Thanks,

Jamie


According to the Managed Object Validation documentation, validation methods are not run until the context is saved, or until you manually validate (with -validateForUpdate:, -validateForInsert:, or -validateForDelete:).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜