返回NSString的首字母大写

Dir*_*age 11 iphone objective-c nsstring uisearchbar

我想返回NSString大写的第一个字母.我有一个UISearchDisplayController根据搜索结果的标题显示部分标题.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    NSString *sectionTitle;
    if (searching) 
        sectionTitle = [searchSectionTitles objectAtIndex:section];
    else
        sectionTitle = [[collation sectionTitles] objectAtIndex:section];

    return sectionTitle;

}
Run Code Online (Sandbox Code Playgroud)

并在我的搜索功能中返回这封信,

[searchSectionTitles addObject:[lastName firstLetter]];
Run Code Online (Sandbox Code Playgroud)

我该怎么做

- (NSString *)firstLetter
Run Code Online (Sandbox Code Playgroud)

返回一个字母的第一个字母NSString

Fie*_*key 40

下面的代码将大写字符串的第一个字母,在这种情况下,大写第一个字母的字符串称为sectionTitle

NSString *firstLetter = [[sectionTitle substringToIndex:1];

firstLetter = [firstLetter uppercaseString];
Run Code Online (Sandbox Code Playgroud)