开发者

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

开发者 https://www.devze.com 2023-03-26 23:14 出处:网络
I implemented a KVC validation method that is called by coredata, but is not being called when I call

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

精彩评论

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

关注公众号