문제

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?

도움이 되었습니까?

해결책

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top