[iOS] 字典序列化对象协议
@interface Book : NSObject <AQSDictionarySerialization>
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *authorName;
@property (nonatomic, copy) NSNumber *isPublished;
@end
@implementaion Book
+ (NSDictionary *)aqs_keyPathsByPropertyKey {
return @{
@"title": @"title",
@"authorName": @"author_name",
@"isPublished": @"is_published"
};
}
@end
然后
[[AQSDictionarySerializer serializer] applyPatchForObject:book withDictionary:@{
@"title": @"Harry Potter",
@"author_name": @"J. K. Rowling",
@"is_published": @(NO)
}];
BOOL
、NSInteger
等...author.name
这样的 keyPath
。