// // Message.m // Juick // // Created by Vitaly Takmazov on 29.10.13. // Copyright (c) 2013 com.juick. All rights reserved. // #import "Message.h" @implementation Message -(id)initWithDictionary:(NSDictionary *)dictionary { Message *result = [[Message alloc] init]; result.MID = [dictionary objectForKey:@"mid"]; result.RID = [dictionary objectForKey:@"rid"]; NSString *text = [[dictionary objectForKey:@"body"] stringByDecodingHTMLEntities]; NSDictionary *userDict = [dictionary objectForKey:@"user"]; result.user = [userDict objectForKey:@"uname"]; NSArray *tagsArray = [dictionary objectForKey:@"tags"]; if ([tagsArray count] > 0) { result.text = [[NSString alloc] initWithFormat:@"%@\n%@", [tagsArray componentsJoinedByString:@", "], text]; } else { result.text = text; } return result; } @end