EDSunriseSet返回0

时间:2014-05-13 19:53:44

标签: datetime time timezone cllocationmanager cllocation

我正在使用https://github.com/erndev/EDSunriseSet

中的EDSunriseSet类

我有代码:

if(longitude == 0 && latitude == 0){
    longitude = 51.50722; latitude = -0.12750;
}


EDSunriseSet *sunrise = [EDSunriseSet sunrisesetWithTimezone:[NSTimeZone localTimeZone] latitude:latitude longitude:longitude];

NSLog(@"With lat = %f and long = %F; sunrise is at: %@",latitude,longitude,sunrise.localSunset);

然后它返回:

<NSDateComponents: 0x10a2743a0>
Hour: 0
Minute: 0
Second: 0

问题是我的结束还是因为脚本已经过时了?

1 个答案:

答案 0 :(得分:2)

所以我很愚蠢,可能应该只阅读源代码。

创建EDSunriseSet对象后,必须调用:

[sunrise calculateSunriseSunset:[NSDate date]];

或者只是把:

[self calculateSunriseSunset:[NSDate date]];

如果您只想使用今天的日期,请进入init方法!