ios - Posting to the webserver the data in iPhone -


i searched can't solve problem .here want post data server. have 1 user default, textview , textfield. please out this.

 nsuserdefaults *getting= [nsuserdefaults standarduserdefaults] ;  userid1=[getting   objectforkey:@"uid"];   nsstring *bodystring=[nsstring stringwithformat:@"userid=%@&question=%@&categoryid=%@",userid1,asktextviewobj.text,specialistfield.text];   [bodystring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];   nslog(@"%@",bodystring);  request=[nsmutableurlrequest requestwithurl:[nsurl urlwithstring:@"xxxxxxxxxxxxxxxxxx" ] cachepolicy:0 timeoutinterval:30];                  [request sethttpmethod:@"post"]; [request sethttpshouldhandlecookies:yes]; [request setvalue:@"application/json" forhttpheaderfield:@"accept"]; [request sethttpbody:[bodystring datausingencoding:nsutf8stringencoding allowlossyconversion:yes]]; [request addvalue:[nsstring stringwithformat:@"%d", [bodystring length]] forhttpheaderfield:@"content-length"]; connection=[nsurlconnection connectionwithrequest:request delegate:self ]; if (!connection) {     uialertview* aler = [[uialertview alloc] initwithtitle:@"network error" message:@"failed connect server " delegate:nil cancelbuttontitle:@"close" otherbuttontitles:nil];     [aler show];  }  else {     nslog(@"connection successfully");  } 


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -