From a74588083c4950e9237dff7a84ccdd129b72c950 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 22 Aug 2016 00:44:28 +0300 Subject: RestKit -> YYModel --- Juick/MessagesViewController.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'Juick/MessagesViewController.m') diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 343bb2c..28e7613 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -48,10 +48,12 @@ static NSString *CellIdentifier = @"MessageCell"; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ self.dataLoading = YES; [Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) { - [self.messages addObjectsFromArray:next]; - [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; - [self.refreshControl performSelectorOnMainThread:@selector(endRefreshing) withObject:nil waitUntilDone:NO]; - self.dataLoading = NO; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.messages addObjectsFromArray:next]; + [self.tableView reloadData]; + [self.refreshControl endRefreshing]; + self.dataLoading = NO; + }); }]; }); } @@ -131,10 +133,12 @@ static NSString *CellIdentifier = @"MessageCell"; if ([msg.attach length] > 0) { __weak MessagesViewController * weakSelf = self; [cell.attach yy_setImageWithURL:[NSURL URLWithString:msg.attach] placeholder:[UIImage imageNamed:@"AttachPlaceholder"] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) { - [cell setNeedsUpdateConstraints]; - [cell updateConstraintsIfNeeded]; - [cell setNeedsLayout]; - [cell layoutIfNeeded]; + dispatch_async(dispatch_get_main_queue(), ^{ + [cell setNeedsUpdateConstraints]; + [cell updateConstraintsIfNeeded]; + [cell setNeedsLayout]; + [cell layoutIfNeeded]; + }); }]; } else { -- cgit v1.2.3