2015-11-02 39 views
0

我正在嘗試在TableView中配置單元格。我正在嘗試做的一件事是更改單元格中文本的字體和顏色。下面是代碼:Objective-C語法錯誤「Expected」]'「

- (void)configureView { 
    UIFont *cellFont = [UIFont fontWithName:@"Raleway-Thin" size:14]; 
    NSDictionary *cellAttributesDictionary = [NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: cellFont]; 
} 

在結腸NSFontAttributeName後,我收到錯誤Expected ']'。什麼導致了這個錯誤?

+2

格式化錯誤。您的字典未被指定爲字典對象。更改爲:'@ {NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:cellFont}' – Stonz2

回答

5

在目標C字面字典正確的語法是@{...};

NSDictionary *cellAttributesDictionary = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: cellFont};