Sam Sam - 1 year ago 204
Swift Question

Error: Expected ',' separator in xcode 8

I migrated my code to Xcode 8 Swift 2.3, and since then getting error in the following line:

func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ())

Error : stating Function types cannot have argument label 'xxxx', use '_' instead. (where xxxx are image and url, both)

following which when I Fix the above errors, it gives Expected ',' seperator and Expected type errors, for the same line which transforms to

func imageForUrl(urlString: String, completionHandler:(_ image: UIImage?, _ url: String) -> ())

How can I fix this issue? please help.

Answer Source

I believe that you are using swift 3. Move last ) before the return

func imageForUrl(urlString : String, completionHandler :(image : UIImage?, url: String) ) -> () {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download