From c3750f7891ab73ed4c4bfa8ddc59969fe77b0d9e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 5 Nov 2013 22:25:33 +0400 Subject: load avatars async --- Juick/MessagesViewController.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Juick/MessagesViewController.m') diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index ac6f99d..1fb4ece 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -16,6 +16,7 @@ #import "ColorsAndButtons.h" #import "NSURL+PathParameters.h" +#import "UIImage+Helpers.h" static NSString *CellIdentifier = @"MessageCell"; @@ -153,7 +154,9 @@ static NSString *CellIdentifier = @"MessageCell"; MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; [cell updateFonts]; Message *msg = [_messages objectAtIndex:indexPath.row]; - [cell.avatar setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]]]]]; + [UIImage loadFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]] callback:^(UIImage *image) { + [cell.avatar setImage:image]; + }]; cell.titleLabel.text = msg.user; cell.titleLabel.textColor = [ColorsAndButtons linkColor]; cell.bodyLabel.text = msg.text; @@ -171,7 +174,10 @@ static NSString *CellIdentifier = @"MessageCell"; [cell updateFonts]; Message *msg = [_messages objectAtIndex:indexPath.row]; - [cell.avatar setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]]]]]; + [UIImage loadFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]] callback:^(UIImage *image) { + [cell.avatar setImage:image]; + }]; + cell.titleLabel.text = msg.user; cell.bodyLabel.text = msg.text; -- cgit v1.2.3