mnbayan / AutocompleteTextfieldSwift

Simple and straightforward sublass of UITextfield to manage string suggestions
MIT License
290 stars 66 forks source link

Swift 3.0 ? #46

Open sourabhsharmait opened 8 years ago

sourabhsharmait commented 8 years ago

Update to Latest Syntax please....

SvshX commented 8 years ago

I can't get it to work with Swift 3. Has anyone been succesful?

sourabhsharmait commented 8 years ago

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 .

SvshX commented 8 years ago

Could you please help me with it?

sourabhsharmait commented 8 years ago

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 .

SvshX commented 8 years ago

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) {

magonicolas commented 7 years ago

How did you make it work on Swift 3?

mloupe commented 7 years ago

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>

magonicolas commented 7 years ago

Thanks @mloupe that did the job!