【发布时间】:2018-11-04 02:08:05
【问题描述】:
从 PromiseKit 4 到 6 的更新是这个...
Promise(foo)
变成了……
.value(foo)
除了我的 ContestListViewController.swift 中的一个实例之外,这对我整个项目的更新都有效。
func confirmEntry(to contest: Contest, with lineup: Lineup) -> Promise<Lineup> {
let entryConfirmationVC = EntryConfirmationViewController()
entryConfirmationVC.configure(for: contest, lineup: lineup)
return entryConfirmationVC.promise().then { seal in return .value(lineup) }
}
这给了我一个错误,上面写着...
Reference to member 'value' cannot be resolved without a contextual type
这里是EntryConfirmationViewController.swift的相关信息
class EntryConfirmationViewController: DraftboardModalViewController {
// 9 variable declarations
// Removed code for readability
let (pendingPromise, seal) = Promise<Void>.pending()
// override func loadView()
// Removed code for readability
func promise() -> Promise<Void> {
let defaults = UserDefaults.standard
if defaults.bool(forKey: App.DefaultsDontAskToConfirmEntry) {
seal.fulfill(())
return pendingPromise
}
RootViewController.sharedInstance.pushModalViewController(nvc: self)
return pendingPromise
}
func configure(for contest: Contest, lineup: Lineup) {
confirmationLabel.text = contest.name.uppercased()
prizeStatView.valueLabel.text = Format.currency.string(from: NSNumber(value: contest.prizePool))
entrantsStatView.valueLabel.text = "\(contest.currentEntries)"
feeStatView.valueLabel.text = Format.currency.string(from: NSNumber(value: contest.buyin))
enterButton.setTitle("Enter “\(lineup.name)”".uppercased(), for: .normal)
}
// @objc func tappedEnterButton()
// Removed code for readability
// @objc func tappedCancelButton()
// Removed code for readability
}
如何让 ContestListViewContoller.swift 中的 confirmEntry 像其他 .value(foo) 调用一样工作?
【问题讨论】:
标签: ios swift xcode uiviewcontroller promisekit