gpt4 book ai didi

ios - 使用未声明的类型 'Date' Xcode 9 Swift 4

转载 作者:可可西里 更新时间:2023-10-31 23:58:40 26 4
gpt4 key购买 nike

这是我在 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
}
}

它显示错误使用未声明的类型“日期”

最佳答案

Date 结构是 Foundation 框架的一部分。

在 playground 的开头添加 import Foundation

作为一般规则,您应该始终至少导入 Foundation,因为我们日常使用的许多类型都是 Foundation 的一部分。您也可以仅导入 UIKit(因为 UIKit 会自动导入 Foundation)。

关于ios - 使用未声明的类型 'Date' Xcode 9 Swift 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com