Ios 如何获得时区缩写

Ios 如何获得时区缩写,ios,uitableview,nstimezone,Ios,Uitableview,Nstimezone,我想创建一个时区列表。 但我在timeZone.缩写处出现了以下错误 -[\uu NSCFString缩写]:发送到实例0x19cb80b0的无法识别的选择器 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIde

我想创建一个时区列表。 但我在timeZone.缩写处出现了以下错误

-[\uu NSCFString缩写]:发送到实例0x19cb80b0的无法识别的选择器

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    // Configure the cell...
    NSTimeZone *timeZone = [[NSTimeZone knownTimeZoneNames] objectAtIndex:indexPath.row];
    cell.textLabel.text = timeZone.abbreviation;  // <- Error Here
    cell.detailTextLabel.text = timeZone.description;
    cell.accessoryType = (timeZone == self.timeZone)? UITableViewCellAccessoryCheckmark :UITableViewCellAccessoryNone;

    return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@“cell”forIndexPath:indexPath];
//配置单元格。。。
NSTimeZone*时区=[[NSTimeZone knownTimeZoneNames]对象索引:indexath.row];

cell.textlab.text=timeZone.缩写;//尝试以下方法:

NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:[[NSTimeZone knownTimeZoneNames] objectAtIndex:indexPath.row]];
cell.textLabel.text = timeZone.abbreviation;  // <- Error Here
cell.detailTextLabel.text = timeZone.description;
NSTimeZone*时区=[NSTimeZone timeZoneWithName:[[NSTimeZone knownTimeZoneNames]对象索引:indexath.row]];
cell.textlab.text=timeZone.缩写;//如下所述:

返回时区的字符串ID列表-因此您的时区对象实际上包含NSString而不是NSTimeZone对象。因此您必须执行以下操作:

NSString *timeZoneID = [[NSTimeZone knownTimeZoneNames] objectAtIndex:indexPath.row];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:timeZoneID];
获取要调用的实时时区对象

NSString *timeZoneID = [[NSTimeZone knownTimeZoneNames] objectAtIndex:indexPath.row];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:timeZoneID];