【问题标题】:Formatting coordinate with NSNumberFormatter使用 NSNumberFormatter 格式化坐标
【发布时间】:2011-04-18 23:49:10
【问题描述】:

我正在尝试使用 NSNumberFormatter 格式化 CLLocation 坐标,以便从数字 44.325290 获得类似 44°32'52.90" N 的东西。

我尝试设置数字格式化程序(查看 documentation),但不起作用。 我无法指定另一个分隔符,例如 ' 和 .

代码:

- (NSNumberFormatter *)coordFormatter {
    if (coordFormatter == nil) {
        coordFormatter = [[NSNumberFormatter alloc] init];
        [coordFormatter setPositiveFormat:@"#0.0#####"];
        [coordFormatter setDecimalSeparator:@"°"];
        [coordFormatter setPositiveSuffix:@"\" N"];
    }
return coordFormatter;
}

使用此代码,我得到一个字符串,如 44°325290" N

有人可以帮助我吗?

【问题讨论】:

  • 4°32'52.90" N 不等于 44.325290。

标签: iphone objective-c nsstring cllocation nsnumberformatter


【解决方案1】:

使用NSString 代替格式或扩展您自己的格式化程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-23
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多