EDSunriseSet returning 0

别等时光非礼了梦想. 提交于 2019-12-13 02:22:59

问题


I am using the EDSunriseSet class from https://github.com/erndev/EDSunriseSet

I have the code:

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);

and it returns:

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

Is the issue on my end or is it because the script is outdated?


回答1:


So I was being rather stupid and probably should have just read the source code.

After creating the EDSunriseSet object, one must call:

[sunrise calculateSunriseSunset:[NSDate date]];

or just put:

[self calculateSunriseSunset:[NSDate date]];

into the init method if you only want to work with todays date!



来源:https://stackoverflow.com/questions/23640380/edsunriseset-returning-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!