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

Compile error when using custom parameters #17

Closed
ghost opened this issue Sep 17, 2014 · 2 comments
Closed

Compile error when using custom parameters #17

ghost opened this issue Sep 17, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 17, 2014

Using custom Dictionary object as parameter in GET request method, Xcode 6(6A313) shows this error

2014-09-17 10 04 58

If taking the same content as the parameter, then it goes well

2014-09-17 10 11 30

Hope someone can fix it

@daltoniam
Copy link
Owner

Alright so this is a weird one, might be a bug in Swift type inference. Adding an explicit type will cause the params to work properly.

let params: Dictionary<String,AnyObject> = ["param": "param1", "array": ["first array element","second","third"], "num": 23, "dict": ["someKey": "someVal"]]
request.GET("http://vluxe.io", method: .GET, parameters: params, success: { (response: HTTPResponse) -> Void in
    println("got stuff back: \(response.statusCode)")
    }) { (error: NSError) -> Void in
        println("request timed out: \(error.localizedDescription)")
}

or moving the Dictionary param variable straight into the parameters argument will do the same thing:

request.GET("http://vluxe.io", method: .GET, parameters: ["param": "param1", "array": ["first array element","second","third"], "num": 23, "dict": ["someKey": "someVal"]], success: { (response: HTTPResponse) -> Void in
    println("got stuff back: \(response.statusCode)")
    }) { (error: NSError) -> Void in
        println("request timed out: \(error.localizedDescription)")
}

I am going to continue to track this down from a Swift standpoint, but the two options above should resolve the issue. I will also updated the docs to reflect this requirement.

@ghost
Copy link
Author

ghost commented Sep 18, 2014

this issue resolved, thank you

@ghost ghost closed this as completed Sep 18, 2014
This issue was closed.
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

1 participant