user2924482
user2924482

Reputation: 9120

Swift: cannot convert value of type <> to expected argument type <> when setting up a selector

I'm getting this error:

cannot convert value of type nsdictionary to expected argument type string

enter image description here
Here is my code:

let json:NSDictionary = try JSONSerialization.jsonObject(with: dataResponse, options: []) as! NSDictionary
self.performSelector(onMainThread: Selector(updateUIwithJsonResponse), with: json, waitUntilDone: true)

performSelector is calling this function:

func updateUIwithJsonResponse(json:NSDictionary) {
print(json)
}

Any of you knows why I'm getting this error?

Upvotes: 0

Views: 1959

Answers (1)

almas
almas

Reputation: 7187

Your method takes a parameter, so try

self.performSelector(onMainThread: #selector(updateUIwithJsonResponse(json:)), with: json, waitUntilDone: true)

Upvotes: 1

Related Questions