[iOS] Dictionary Serializable Object Protocol
@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
Then
[[AQSDictionarySerializer serializer] applyPatchForObject:book withDictionary:@{
@"title": @"Harry Potter",
@"author_name": @"J. K. Rowling",
@"is_published": @(NO)
}];
- You cannot use primitive properties such as
BOOL
,NSInteger
, etc... - Currently you cannot use
keyPath
such asauthor.name
.