【问题标题】:Unable to get postal code from CLGeocoder无法从 CLGeocoder 获取邮政编码
【发布时间】:2019-08-02 23:59:52
【问题描述】:

我正在尝试从 CLGeocoder 获取邮政编码,但应用程序因错误 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument' 而崩溃

这是我的代码

CLPlacemark *placemark = [placemarks objectAtIndex:0];
             NSString *Postalcode = [[NSString alloc]initWithString:placemark.postalCode];
             NSLog(@"Postal : %@",Postalcode);

输出为“空”

【问题讨论】:

标签: objective-c clgeocoder


【解决方案1】:

在将NSString 传递给init 之前,您应该检查placemark.postalCode 检查它是否为零。

【讨论】:

    猜你喜欢
    • 2017-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-21
    • 2013-04-05
    • 2013-02-08
    • 1970-01-01
    相关资源
    最近更新 更多