2013-12-18 82 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]; 

    }); 

    }); 
}