这是我在 xcode 9 Playground 中的代码
class Tutorial: Codable {
let title: String
let author: String
let editor: String
let type: String
let publishDate: Date
init(title: String, author: String, editor: String, type: String, publishDate: Date) {
self.title = title
self.author = author
self.editor = editor
self.type = type
self.publishDate = publishDate
}
}
它显示错误使用未声明的类型“日期”
The Date
结构体是的一部分Foundation
框架。
Add import Foundation
在你的游乐场的开始处。
作为一般规则,您应该始终至少导入Foundation
因为我们使用的许多日常类型都是Foundation
。您也可以仅导入UIKit
(因为UIKit
自动导入Foundation
).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)