Ios 客观错误。Xcode不确定代码出了什么问题

Ios 客观错误。Xcode不确定代码出了什么问题,ios,objective-c,cocoa-touch,Ios,Objective C,Cocoa Touch,它给了我一个错误,说我在程序中缺少了一个@end,意料之外的@,它希望在代码的末尾有一个封闭的括号 #import "TweetCell.h" #import "AppDelegate.h" @implementation TweetCell @synthesize tweetLabel = _tweetLabel; @synthesize userImage = _userImage; @synthesize usernameLabel = _usernameLabel; - (UI

它给了我一个错误,说我在程序中缺少了一个@end,意料之外的@,它希望在代码的末尾有一个封闭的括号

#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];
        });

    });
    }
@end

你缺少一个结束括号。在方法末尾的@end

之前添加一个,返回UITableViewCell,如下所示:


如何发现错误:

全选 复制 粘贴 这将导致Xcode在粘贴代码时重新格式化代码

你应该注意到@end在后面缩进了,这是因为你有一个左大括号,而没有一个匹配的右大括号

添加大括号。你可以用command-A,command-C,command-V序列再次检查


HTH

。。。它希望在代码的末尾有一个封闭的括号,那么为什么不添加它呢?使用Xcode中的自动缩进,实际上很容易找到匹配或不匹配的括号。他也从不创建单元格。实际上这是一个双柱:现在它说,当我添加括号时,控件到达非空函数的末尾。不确定要做什么。您需要返回一个UITableViewCellnon void function=方法的实例,该方法返回一些内容。可以为零。只需输入返回单元格;在方法的最后,我爱你们,最好的社区!首先,他必须创建一个单元格
return cell;