2013-12-18 65 views
-2

我得到一个错误但我不知道为什么我得到它。它想要一个“(”之前别的。Xcode 5鬼错误

这里是整个事情。

#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

我们需要看到的代码* *前开'else',后不是(这个代码看起来语法正确) – Tim

+0

结束的方括号东西之前,似乎封闭法,T其他方法不在任何方法之内。看起来像一个错字。 – JOM

回答

0

移动之前,否则支架的方法结束

0

更改else和支架放置到如下:

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]; 

    }); 

    }); 
}