Reputation: 9759
I'm building a class to act as my API helper and I've nested an enum inside my class to show the response state:
class API {
enum Response {
case Success, Error, ServerError, ClientError
}
func load(handleResponse ((API.Response, JSON?) -> Void)) {
// Load in data with Alamofire
// Call handleResponse(.Success, data) at some point
}
}
To use my API, I am trying to write something like the following:
API.load { (status: API.Response, data: JSON?) in
...
}
I'm getting an error as follows with my code above:
Cannot convert value of type '(API.Response, JSON?) -> ()' to expected argument type 'API'
It seems like the '.' in the type is a problem, but I'm not sure how to fix it.
Upvotes: 0
Views: 59
Reputation: 59536
Please try this
class API {
enum Response {
case Success, Error, ServerError, ClientError
}
class func load(handleResponse: ((API.Response, JSON?) -> ())) {
}
}
API.load { (response, json) -> () in
}
Upvotes: 1