如何获取CLLocation的时区名称 [英] How to get the time zone name for a CLLocation

查看:137
本文介绍了如何获取CLLocation的时区名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用CLGeocoder从地址字符串中对地标进行地理编码的应用程序. CLPlacemark响应包含一个CLLocation,可为我提供GPS坐标.

I have an application that uses a CLGeocoder to forwardGeocode a placemark from an address string. The CLPlacemark response contains a CLLocation which gives me GPS coordinates.

创建NSTimeZone的唯一方法似乎是使用正确的时区名称.重要的是要指出我没有使用设备的当前位置,因此[NSTimeZone localTimeZone]对我不起作用.

The only way to create an NSTimeZone seems to be by using the correct Time Zone Name. It is important to point out that I am not using the current location of the device, so [NSTimeZone localTimeZone] will not work for me.

是否可以获取CLLocation的时区名称,以便我可以正确创建NSTimeZone?

Is there a way to get the timezone name for the CLLocation so that I can create an NSTimeZone correctly?

注意:我一直在使用timeZoneForSecondsFromGMT,但是它从未包含正确的DST数据,因此对我没有帮助.

NOTE: I have been using timeZoneForSecondsFromGMT but that never contains correct DST data, so it is not helpful for me.

推荐答案

您应使用 https://github. com/Alterplay/APTimeZones 从CLLocation获取NSTimeZone.它也可以与CLGeocoder一起使用.

You should use https://github.com/Alterplay/APTimeZones to get NSTimeZone from CLLocation. It also works with CLGeocoder.

这篇关于如何获取CLLocation的时区名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆