iphone - How to send JSON data over NSURLConnection -
i have created method connects web service , posts string , receives string response. however, trying post json dictionary created using nsjsonserialization. however, xcode giving me error. have tried convert initial code. relevant lines below...
nsdata* logindatajson = [nsjsonserialization datawithjsonobject:logindatadictionary options:nsjsonwritingprettyprinted error:&error]; [request setvalue:logindatajson forhttpheaderfield:@"logindatajson"]; [request sethttpbody:[logindatajson datausingencoding:nsutf8stringencoding]]; the second line heres complains using nsdata nsstring required. third line complains logindatajson may not respond datausingenconding
i seem forcing nsdata object (because nsjsonserialization gives me) cannot used. best trying convert json string use existing request code, or should/can change request code accept nsdata opposed nsstring?
have tried use frameworks jsonkit or restkit? restkit specially used webservice communication json , internally uses jsonkit , 1 parser. think solve problem , maybe future 1 ;)
Comments
Post a Comment