问题
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