【发布时间】:2017-07-13 16:51:04
【问题描述】:
我正在使用这种方法从lat/long 获取timeZone。
-(void)getTimeZoneFromLatLong
{
CLLocation *location = [[CLLocation alloc] initWithLatitude:self.parentVC.currentCity.latitude.doubleValue longitude:self.parentVC.currentCity.longitude.doubleValue];
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
[geoCoder reverseGeocodeLocation: location completionHandler:^(NSArray *placemarks, NSError *error)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
_placemark = placemark;
}];
}
然后我可以使用timeZone 来调用:
EDSunriseSet *eds = [EDSunriseSet sunrisesetWithTimezone:_placemark.timeZone
latitude:latitude.doubleValue longitude:longitude.doubleValue];
EDSunriseSet 是一个库,用于从 lat/long 和 timeZone 获取 Sunrise/Sunset 值。
它运行良好,但是Crashlytics 提醒我[CLPlacemark timeZone] 与iOS8 及更低版本不兼容。
如何调整我的代码以适应 iOS8 ?
编辑: [_placemark timezone] 和 _placemark.timezone 都被接受?
【问题讨论】:
-
这正是我正在做的事情
-
不,您没有正确阅读。这个问题是iOS9之前的问题。他们正在使用
CLPlaceMark的timeZone属性从其 loc/lat 中检索 NSTimeZone(因为它当时不存在)。 -
我无法结束这个问题。我需要答案。我使用了您链接中的 chris 解决方案。
标签: ios objective-c swift timezone selector