iphone - Get a request twice? -


i using below code send request web-service , response , here got request twice @ time ,i dont did mistake,help me come out issue. in advance.

 nsstring *poststr=[nsstring stringwithformat:@"&cname=%@&conname=%@&email=%@",companynametxt.text,contactnametxt.text,contactemailtxt.text]; nslog(@"poststr %@",poststr);   nsdata *postdata = [poststr datausingencoding:nsasciistringencoding allowlossyconversion:yes];   nsstring *postlength = [nsstring stringwithformat:@"%d", [postdata length]];  nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring: @"web servicess"]]; [request sethttpmethod:@"post"]; [request sethttpbody:postdata];  [request setvalue:postlength forhttpheaderfield:@"content-length"]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:request delegate:self]; nslog(@"data%@",theconnection); [theconnection release]; nserror *error; nsurlresponse *response; nsdata *urldata=[nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error];  nsstring *filenamestr=[[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding];  nslog(@"filenamestr %@",filenamestr); 

you making 2 separate calls

nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:request delegate:self]; 

and

nsdata *urldata=[nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error]; 

use either 1 of them not both.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -