Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument labels '(_:)' do not match any available overloads #582

Closed
mirzadelic opened this issue Sep 17, 2016 · 4 comments
Closed

Argument labels '(_:)' do not match any available overloads #582

mirzadelic opened this issue Sep 17, 2016 · 4 comments

Comments

@mirzadelic
Copy link

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?

@ardacetinkaya
Copy link

I have the same error.

@robbiet480
Copy link

robbiet480 commented Sep 17, 2016

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()!)

@tristanhimmelman
Copy link
Owner

@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()!)

@keyss-sachin-arora
Copy link

i have the same error with this .
var token = deviceToken.description.trimmingCharacters(in: CharacterSet(charactersInString:"<>" ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants