Swift 3中的日历已更改? [英] Calendar Changed in Swift 3?

查看:368
本文介绍了Swift 3中的日历已更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在处理这个小应用程式,我

Hey so I'm working on this little app and I

let durationDateComponents = Calendar(identifier: Calendar.Identifier.gregorian).dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date(), to: christmasDay, options: [])

我该怎么办?我得到的错误是指向我改变一些数组,但什么?

What do I do here? I get that the error is pointing me to change something with the array, but what?

谢谢!

推荐答案

删除选项。这不是 dateComponents ,因此编译器无法识别该方法。

Remove options. That's not part of dateComponents and thus the compiler is having trouble identifying the method.

let calendar = Calendar.current   // or, if you really need gregorian calendar regardless of the current calendar, `Calendar(identifier: .gregorian)`
let components = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date(), to: christmasDay)



如果删除 / code>,方法被成功识别,因此它能够正确解释表达式。

If you remove options, the method is successfully identified and therefore it is able to correctly interpret the expression.

这篇关于Swift 3中的日历已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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