在 Xcode 中显示一个错误,显示“无法将 'NSCalendar.Unit' 类型的值转换为预期的参数类型 'Set'”。
出现此错误的代码行如下:
let dateComponents = NSCalendar.current.dateComponents(NSCalendar.Unit.year, from: <Date>, to: <Date>)
问题是我尝试过的“NSCalendar.Unit.year”不正确。如何在 Apple 的文档中搜索正确的解决方案?我尝试了 Google 搜索,但它会显示各种博客,但我正试图更倾向于从 Apple 的文档中寻找解决方案。