【发布时间】: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