// // Message.m // Juick // // Created by Vitaly Takmazov on 29.10.13. // Copyright (c) 2013 com.juick. All rights reserved. // #import "Message.h" @implementation Message + (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"] boolValue]; message.unread = [jsonData[@"unread"] boolValue]; 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