【发布时间】:2019-01-24 07:29:01
【问题描述】:
我已经多次遇到这个错误,但我不确定它是什么意思。我试图在网上寻找解决方案,但没有一个专门解决 .type 的问题。
这是我当前的错误:
private func setUpCache() {
let urlCache: URLCache = URLCache(memoryCapacity: MEMORY_CAPACITY, diskCapacity: DISK_CAPACITY, diskPath: "myDiskPath")
URLCache.shared = URLCache //<-Cannot assign value of type 'URLCache.type' to type 'URLCache'
}
我已经看到这个错误也发生在其他类型上。和 Int 成为 Int.type 或 String 成为 string.type 等意味着什么
【问题讨论】:
-
您需要分配
URLCache的实例,而不是URLCache本身的类。 -
这是最近的变化吗?其他在线示例(例如:stackoverflow.com/questions/38249573/…)似乎表明这很好。谢谢你的回答!
-
那些例子并没有做你在自己的问题中所做的事情。
标签: swift