How to get and Insert data in JSON Parsing in IOS6 -
how , insert data in json parsing in ios6
i trying insert data in json link , retrieve data json link using jsonparser.
how can use json parser without adding json frame work in ios6.
first need import json files you'll here
then if using post method following :
nsstring *myrequeststring = [nsstring stringwithformat:@"u=%@&p= %@",struname,strpassword]; myrequeststring=[myrequeststring stringbyreplacingoccurrencesofstring:@" " withstring:@""]; nsdata *myrequestdata = [nsdata datawithbytes:[myrequeststring utf8string] length:[myrequeststring length]]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring: @"your webservice url"]]; [request sethttpmethod:@"post"]; [request sethttpbody:myrequestdata]; nsdata *returndata = nil; returndata = [nsurlconnection sendsynchronousrequest:request returningresponse:nil error:nil]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; nsdictionary *mydic = [nsjsonserialization jsonobjectwithdata:returndata options:nsjsonreadingmutableleaves error:nil];
if using method use following :
nsdata *data = [nsdata datawithcontentsofurl:[nsurl urlwithstring:[nsstring stringwithformat:@"your webservice parameters in url"]]]; nsdictionary *mydic = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutableleaves error:nil];
hope help.
Comments
Post a Comment