EDSunriseSet返回0 [英] EDSunriseSet returning 0

查看:313
本文介绍了EDSunriseSet返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 https://github.com/erndev/EDSunriseSet 中的EDSunriseSet类p>

我有代码:

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


EDSunriseSet * sunrise = [EDSunriseSet sunrisesetWithTimezone:[NSTimeZone localTimeZone]纬度:纬度经度:经度];

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

并返回:

 < NSDateComponents:0x10a2743a0> 
小时:0
分钟:0
秒:0

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

解决方案

所以我很笨,可能应该只需读取源代码。



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

 code> [sunrise calculateSunriseSunset:[NSDate date]]; 

或只是放:

  [self calculateSunriseSunset:[NSDate date]]; 

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


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!

这篇关于EDSunriseSet返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆