swift - 如何将 NSDateComponent 作为函数参数传递
问题描述
如何将 NSDateComponent 对象或引用作为函数参数(只读)传递?以下代码在“编译”时失败,并出现“使用未声明的类型 'NSDateComponent'”错误:
import Foundation
class PreventativeCare {
var birthday = NSDateComponents()
func setPatientDOB(birthdate:NSDateComponent /* compile error */ ) {
birthday.day = birthdate.day
birthday.month = birthdate.month
birthday.year = birthdate.year
}
}
解决方案
将 NSDateComponent 更正为 NSDateComponents 并且效果很好。
推荐阅读
- r - 用 ggplot2 绘制单变量持续时间序列数据
- python - Pyspark - Python 设置相同的时区
- javascript - Arangosh 查询在 30 分钟后超时
- apache-tomee - Tomee MP-JWT:组到角色的映射
- sql - 如果 GROUP BY 之后有 > 1 条记录,则显示 'MULTIPLE_VALUES' 而不是 LISTAGG
- c++ - 使用函数作为回调时,有没有办法避免存储开销?
- react-native - Infinite FlatList 中的多个轮播分页同步问题
- kubernetes - 访问本地网络上的云 kubenates 服务
- python - 如何给多个 if 语句一个重新组合的输出?
- r - 选择大范围的值以在 R 中重新编码