我收到错误但是我不确定为什么我会收到错误。它想要一个'('在其他之前。
以下是整个事情。
#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];
});
});
}
答案 0 :(得分:0)
将括号前面的括号移到方法的末尾
答案 1 :(得分:0)
将您的其他人和支架位置更改为以下内容:
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];
});
});
}