简体   繁体   中英

Objective-C syntax error “Expected ']'”

I am attempting to configure cells in a TableView . One of the things I am trying to do is change the font and color of the text in the cells. Here is the code:

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

At the colon after NSFontAttributeName I am getting the error Expected ']' . What is causing this error?

在Objective-C中,字典文字的正确语法为@{...};

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM