Decodable' is ambiguous for type lookup in this context (Swift4)
msalmaniftikhar opened this issue · 1 comments
msalmaniftikhar commented
we are updating our app from swift3 to swift4.
Error Messages
Decodable' is ambiguous for type lookup in this context. Cannot convert value of type '([DiaryDecodable.MeetingType]?) -> DiaryDecodable' (aka '(Optional<Array>) -> DiaryDecodable'
Sample JSON
{
"_links": [],
"resource": [
{
"keyName": "key1",
"value": "Meeting Location"
},
{
"keyName": "key2",
"value": "Meeting Details"
}
}
Models
All models involved, including their Decodable
implementations.
struct DiaryDecodable: Diary {
typealias MeetingType = MeetingDecodable
var meetings: [MeetingType]? = nil
}
extension DiaryDecodable: Decodable {
static func decode(_ j: JSON) -> Decoded<DiaryDecodable> {
let diary = curry(DiaryDecodable.init(meetings:))
return diary
<^> j <||? "resource"
}
}
import Foundation
import Argo
import Runes
import ReactiveSwift
import Curry
Argo Version
Argo 4.1.2
Dependency Manager
Carthage
msalmaniftikhar commented
Resolved it using below code
struct DiaryDecodable: Diary {
typealias MeetingType = MeetingDecodable
var meetings: [MeetingType]? = nil
}
extension DiaryDecodable: Argo.Decodable {
static func decode(_ j: JSON) -> Decoded<DiaryDecodable> {
return curry(DiaryDecodable.init(meetings:))
<^> j <||? "resource"
}
}