Open sourabhsharmait opened 8 years ago
I can't get it to work with Swift 3. Has anyone been succesful?
Yes
On 16-Nov-2016 5:48 pm, "Sascha Melcher" notifications@github.com wrote:
I can't get it to work with Swift 3. Has anyone been succesful?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mnbayan/AutocompleteTextfieldSwift/issues/46#issuecomment-260932349, or mute the thread https://github.com/notifications/unsubscribe-auth/ALifp1rNaGuoIJ_zZq4urxhUJ6rF-o3Lks5q-vR3gaJpZM4KUqaL .
Could you please help me with it?
Yes i will but on monday
On 19-Nov-2016 12:10 am, "Sascha Melcher" notifications@github.com wrote:
Could you please help me with it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mnbayan/AutocompleteTextfieldSwift/issues/46#issuecomment-261607784, or mute the thread https://github.com/notifications/unsubscribe-auth/ALifp3b3MahueNWvjp-pYWE6mRw9-Osbks5q_fEJgaJpZM4KUqaL .
Thanks! My main issue is in the fetchAutoCompletePlaces function. The url for Google Places API cannot be used like in Swift 2 anymore. Now I'm using this but it shows STATUS: "unable to read data":
let urlString = "\(baseURLString)?key=\(googleMapsKey)&input=\(keyword)" let s = NSMutableCharacterSet() //create an empty mutable set s.formUnion(with: NSCharacterSet.urlQueryAllowed) // let s = NSCharacterSet.URLQueryAllowedCharacterSet.mutableCopy() as! NSMutableCharacterSet s.addCharacters(in: "+&") if let encodedString = urlString.addingPercentEncoding(withAllowedCharacters: s as CharacterSet) {
How did you make it work on Swift 3?
It worked fine for me, but at first didn't compile.
In the fetchAutoCompletePlaces function, change:
let result = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
to
let result = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! Dictionary<String,Any>
Thanks @mloupe that did the job!
Update to Latest Syntax please....