Reference to generic type 'Map' requires arguments in <...> - Swift

Viewed 2183

After updating the Xcode to 12.5 and updating all the pods , i start getting the above error in all files where mapping is happening

Reference to generic type 'Map' requires arguments in <...> Insert '<<#Key: _MapKey#>, <#Value: RealmCollectionValue#>>'

class DayPartData: Object, Mappable {
    @objc dynamic var code = 0
    @objc dynamic var text : String?

    required convenience init?(map: Map) {
        self.init()
    }

    func mapping(map: Map) {
        code <- map["code"]
        text <- map["text"]
    }
}

am I missing something here?

2 Answers

Realm has added new collection type 'Map<String, T> ', It's like a Dictionary. coincidentally, Map is a class belongs to ObjectMapper. So, You just need to add ‘ObjectMapper’ before the ‘ Map’ to distinguish it. like this

class DayPartData: Object, Mappable {
@objc dynamic var code = 0
@objc dynamic var text : String?
required convenience init?(map: ObjectMapper.Map) {
    self.init()
}
func mapping(map: ObjectMapper.Map) {
    code <- map["code"]
    text <- map["text"]
}

Try to use realm version 10.7.6 instead of new. Because after they added new Map<> type. I had the same error 2 hours ago.)

Related