【发布时间】:2019-08-22 13:29:34
【问题描述】:
我收到一个错误提示
无法推断通用参数“D”显式指定通用参数以解决此问题
也许是因为代码是用 swift 3 编写的,现在他们改变了语法,所以如果有人可以帮助我的话。
这是我的代码:
listMonitor = dataStack.monitorList(From<Task>(), OrderBy(.descending("date")))
当我删除 OrderBy 时,它可以工作:
工作代码:
listMonitor = dataStack.monitorList(From<Task>())
监控列表代码:
public func monitorList<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
CoreStore.assert(
Thread.isMainThread,
"Attempted to observe objects from \(cs_typeName(self)) outside the main thread."
)
return ListMonitor(
dataStack: self,
from: from,
sectionBy: nil,
applyFetchClauses: { fetchRequest in
fetchClauses.forEach { $0.applyToFetchRequest(fetchRequest) }
CoreStore.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(cs_typeName(ListMonitor<D>.self)) requires a sort information. Specify from a \(cs_typeName(OrderBy<D>.self)) clause or any custom \(cs_typeName(FetchClause.self)) that provides a sort descriptor."
)
}
)
}
【问题讨论】:
-
你的监视器列表里面有什么
-
可以添加
monitorList函数的声明吗? -
@guru 我用 monitorList 代码更新代码
-
@Kolineal 我用 monitorList 代码更新代码
标签: ios arrays swift xcode corestore