![](/img/trans.png)
[英]cannot convert value of type '()' to expected argument '() -> void'
[英]Cannot convert value of type '[CustomObject]' to expected argument type '[_]'
這是類聲明:
class VXDropdownFormRow<T: SelectableOption>: DropdownFormRow<T> where T: Equatable {
override init(title: String?, options: [T], selectedOption: T?, cellSelection: FormCellSelectionClosureType?, valueChanged: ((FormRow) -> Void)?) {
super.init(title: title, options: options, selectedOption: selectedOption, cellSelection: cellSelection, valueChanged: valueChanged)
self.cellHeight = 74
}
}
我從另一個班級叫它:
formRow = VXDropdownFormRow(title:NSLocalizedString(“ xyz”,comment:“”).uppercased(),選項:durationArray,selectedOption:contractDurationtItem,cellSelection:nil,valueChanged:{(row)in self.contract.duration = row.value as?ContractDuration})
durationArray
是:
var durationArray : [ListItem]
它符合協議SelectableOption
如在類的聲明中所述:
open class ListItem: NSManagedObject, SelectableOption {
func setValues(fromJSON json: JSON, sortOrder: Int) {
defaultValue = json["default"].stringValue == "true" ? (true) : (false)
value = json["value"].stringValue
text = json["text"].stringValue
localSortOrder = (sortOrder as NSNumber?)
}
public func selectableOptionTitle() -> String {
return self.text!
}
public func selectableOptionSectionTitle() -> String {
return ""
}
}
但是編譯器在構建時拋出錯誤:
Cannot convert value of type '[ListItem]' to expected argument type '[_]'
我該怎么辦才能解決此錯誤?
我通過修復文件中的原始聲明來解決此問題,該文件設置為VXDropdownFormRow<OldClassName>
。 請檢查聲明以確保一切正確。 此錯誤會誤導您,也無法幫助您找到問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.