diff options
author | Vitaly Takmazov | 2018-12-02 23:23:31 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-12-02 23:23:31 +0300 |
commit | a293a8e049fea49b8c2b8262fb92a29f73d66989 (patch) | |
tree | 2201a139fc19fcac59714e915f08b0aa7e816517 /Juick/Model/Message.m | |
parent | 3bc3a38be7ccaf9622bdc86ffac37827af36f0f1 (diff) |
Drop YYModel
Diffstat (limited to 'Juick/Model/Message.m')
-rw-r--r-- | Juick/Model/Message.m | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m index d00f705..68cc7c9 100644 --- a/Juick/Model/Message.m +++ b/Juick/Model/Message.m @@ -11,10 +11,24 @@ @implementation Message -+ (NSDictionary *)modelCustomPropertyMapper { - return @{@"text" : @"body", - @"attach" : @"photo.small", - @"repliesCount": @"replies", - @"repliesBy": @"repliesby"}; ++ (Message *) fromJSON:(NSDictionary *)jsonData { + Message * message = [Message new]; + message.mid = jsonData[@"mid"]; + message.rid = jsonData[@"rid"]; + message.text = jsonData[@"body"]; + message.attach = jsonData[@"photo"][@"small"]; + message.repliesCount = jsonData[@"replies"]; + message.repliesBy = jsonData[@"repliesby"]; + message.user = [User fromJSON:jsonData[@"user"]]; + message.timestamp = jsonData[@"timestamp"]; + message.service = jsonData[@"service"]; + message.tags = jsonData[@"tags"]; + NSMutableArray *entitiesArray = [NSMutableArray new]; + for (NSDictionary *entityData in jsonData[@"entities"]) { + [entitiesArray addObject:[Entity fromJSON:entityData]]; + } + message.entities = [entitiesArray copy]; + message.attachment = [Attachment fromJSON:jsonData[@"attachment"]]; + return message; } @end |