I am getting an error But I am not sure why I am getting it. It wants a '(' before else.
Here is the whole thing.
#import "TweetCell.h"
#import "AppDelegate.h"
@implementation TweetCell
@synthesize tweetLabel = _tweetLabel;
@synthesize userImage = _userImage;
@synthesize usernameLabel = _usernameLabel;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ContentCell";
TweetCell *cell = [tableView dequeueReusableCellWithIdentifier:indexPath];
NSDictionary *currentTweet = [self.tweetsArray objectAtIndex:indexPath.row];
NSDictionary *currentUser = [currentTweet objectForKey:@"user"];
cell.usernameLabel.text = [currentTweet objectForKey:@"name"];
cell.tweetLabel.text = [currentTweet objectForKey:@"text"];
cell.userImage.image = [UIImage imageNamed:@"image.png"];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSString *userName = cell.usernameLabel.text;
if ([appDelegate.profileImages objectForKey:userName]) {
cell.userImage.image = [appDelegate.profileImages objectForKey:userName];
}
}
else {
dispatch_queue_t conccurentQueue = dispatch_get_global_queue(dispatch_get_global_queue, 0);
dispatch_async(conccurentQueue, ^{
NSURL *imageURL = [NSURL URLWithString:[currentUser objectForKey:@"image.png"]];
__block NSData *imageData;
dispatch_sync(conccurentQueue, ^{
imageData = [NSData dataWithContentsOfURL:imageURL];
[AppDelegate.profileImages setObject:[UIImage imageWithData:imageData] forKey:userName];
});
});
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…