swift - Google url shortener iOS -


trying short version of url using googleshortener api. using afnetworking 3.0 , error: 'anyobject not subtype of 'nsproxy'

let manager = afhttpsessionmanager()     manager.requestserializer = afjsonrequestserializer()     let params = ["longurl": "myurl"]       manager.post("https://www.googleapis.com/urlshortener/v1/url?key=mykey", parameters: params, success: {(operation: nsurlsession!,responseobject: anyobject!) in         println("json" + responseobject.description)         },                    failure: { (operation: nsurlsession!,error: nserror!) in         println("error while requesting shortened: " + error.localizeddescription)     }) 

it highlighted on line 'println("json" + responseobject.description)' on begging of 'description'.

i had same error while using afnetworking 3. documentation indicated there changes. however, here code able run. hope works out.

let manager = afhttpsessionmanager() manager.requestserializer = afjsonrequestserializer() let params = ["longurl": "myurl"]   manager.post("https://www.googleapis.com/urlshortener/v1/url?key=mykey", parameters: params, success: {(operation: nsurlsessiondatatask!,responseobject: anyobject?) in     print("json" + (responseobject?.description)!)     },                failure: { (operation: nsurlsessiondatatask?,error: nserror) in     print("error while requesting shortened: " + error.localizeddescription) }) 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -