1
我正在使用第三方庫,並且出現了我不明白的錯誤(我是Swift新手)。Swift 3 Swift 4 kishikawakatsumi/SpreadsheetView
下面的代碼:
final class ReusableCollection<Reusable>: Sequence where Reusable: NSObject {
var pairs = [Address: Reusable]()
var addresses = Set<Address>()
var objects: LazyMapCollection<[Address: Reusable], Reusable> {
return pairs.values
}
func contains(_ member: Address) -> Bool {
return addresses.contains(member)
}
@discardableResult
func insert(_ newMember: Address) -> (inserted: Bool, memberAfterInsert: Address) {
return addresses.insert(newMember)
}
func subtract(_ other: Set<Address>) {
addresses.subtract(other)
}
subscript(key: Address) -> Reusable? {
get {
return pairs[key]
}
set(newValue) {
pairs[key] = newValue
}
}
func makeIterator() -> LazyMapIterator<DictionaryIterator<Address, Reusable>, Reusable> {
return pairs.values.makeIterator()
}
在return pairs.values
我得到這個錯誤:
"Cannot convert return expression of type 'Dictionary.Values' to return type 'LazyMapCollection<[Address : Reusable], Reusable>'"
而且在最後一行我得到這個錯誤:
"Ambiguous reference to member 'makeIterator()'"
此外我還有:
let mergedCells = dataSource.mergedCells(in: self)
let mergedCellLayouts: [Location: CellRange] = { _ in
var layouts = [Location: CellRange]()
在這裏,我得到這個錯誤:
"Cannot convert value of type '(_) -> _' to specified type '[Location : CellRange]'"
任何想法?我做了一些研究,但我一直無法解決這個問題。