简体   繁体   中英

Core data encrypted attributes

we want to encrypt some attributes of our entity, but still be able to perform fetches and predicates using the attribute, without the special care for predicates and etc...

person attribute name is encrypted

NSPredicate * predicate = [NSPredicate predicateWithFormat:@"name like JOHN"];
johns = [persons filteredArrayUsingPredicate: predicate];

core data entity

.h

@interface Person : NSManagedObject

@property (nonatomic, retain) NSString * name; // crypted
@property (nonatomic, retain) NSString * description; // crypted
@property (nonatomic, retain) NSString * someAtrribute;

@end

.m

@implementation File

@dynamic name;
@dynamic description;
@dynamic someAttribute;

@end
  • i cannot change @dynamic to @synthesize and implement my custom setter and getter
  • i could change the encrypted property to c_name and add a synthesized property name with custom getter and setter, but this won't work on predicates

您实际上可以实现自定义访问器方法,请阅读此apple doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM