I have model:
class Branch: Mappable {
var id: Int!
var name: String!
var city: String!
var address: String!
var base_url: String!
var image: String?
var caffe: Bool!
var restaurant: Bool!
var latitude: String!
var longitude: String!
var phone: String!
var mobtel: String!
var ft_count: Int!
var ft_grouped_count: String!
required init?(map: Map) {
}
func mapping(map: Map) {
id <- map["id"]
name <- map["name"]
city <- map["city"]
address <- map["address"]
base_url <- map["base_url"]
image <- map["image"]
caffe <- map["caffe"]
restaurant <- map["restaurant"]
latitude <- map["latitude"]
longitude <- map["longitude"]
phone <- map["phone"]
mobtel <- map["mobtel"]
}
}
and:
let jsonObj = JSON(response.result.value)
for obj in jsonObj {
let branch = Mapper<Branch>().map(obj.1.rawString()!) // error here
self.results.append(branch!)
}
but i am getting error:
Argument labels '(_:)' do not match any available overloads
on this line let branch = Mapper<Branch>().map(obj.1.rawString()!)
.
This worked before, is this bug?
I have the same error.
Assuming that you have a JSON string, you should be able to fix the issue by changing to this:
let branch = Mapper<Branch>().map(JSONString: obj.1.rawString()!)
@robbiet480 is correct. This is not a bug, but a change in the API. Mapper now uses named parameters in most of its functions.
There is a new API that you can use to map your objects. There is an extension on Mappable
that provides initializer based mapping for your objects that conform to Mappable
. Here is an example for your situation:
let branch = Branch(JSONString: obj.1.rawString()!)
i have the same error with this .
var token = deviceToken.description.trimmingCharacters(in: CharacterSet(charactersInString:"<>" ))
Most helpful comment
@robbiet480 is correct. This is not a bug, but a change in the API. Mapper now uses named parameters in most of its functions.
There is a new API that you can use to map your objects. There is an extension on
Mappable
that provides initializer based mapping for your objects that conform toMappable
. Here is an example for your situation: