uitextfield - how to send values to server in iOS -


i want send value server ,i getting message values inserted @ time of fetching value null, code sample.

-(void)requestreturneddata:(nsdata *)data{ //activated when data returned         nsdictionary *dictionary = [nsdictionary dictionarywithjsondata:data];         output.text = dictionary.jsonstring;           value1textfield.text =[dictionary objectforkey:@"productdescription"] ;         nslog(@"val1",value1textfield.text);      value2textfield.text = [dictionary objectforkey:@"productid"];      value3textfield.text = [dictionary objectforkey:@"productimageurl"];      value4textfield.text = [dictionary objectforkey:@"productname"];      value5textfield.text = [dictionary objectforkey:@"productprice"];      value6textfield.text = [dictionary objectforkey:@"productrating"];     value7textfield.text = [dictionary objectforkey:@"productreviews"];      nslog(@"%@",dictionary); } -(void)gettest{    nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:@" http://www.mobdevapp.com/iphapi/getproductdetail.php"]];      [request sethttpmethod:@"get"];     [request addvalue:@"getvalues" forhttpheaderfield:@"method"];      //selects task server perform      //initialize nsurlconnection  request     nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self];     if(!connection){         nslog(@"connection failed");     }  }  -(void)posttest{      //build request sent server     nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:[nsurl urlwithstring:@"http://www.mobdevapp.com/iphapi/productdetail.php"]];      [request sethttpmethod:@"post"];     [request addvalue:@"postvalues" forhttpheaderfield:@"method"];      //create data sent in post     nsmutabledictionary *dictionary = [[nsmutabledictionary alloc] init];    [dictionary setvalue: @"" forkey:@"productdescription"];      [dictionary setvalue:@"" forkey:@"productid"];     [dictionary setvalue: @"" forkey:@"productimageurl"];     [dictionary setvalue:@"" forkey:@"productname"];     [dictionary setvalue: @"" forkey:@"productprice"];     [dictionary setvalue:@"" forkey:@"productrating"];     [dictionary setvalue:@"" forkey:@"productreviews"];      //serialize dictionary data json     nsdata *data = [[dictionary copy] jsonvalue];      [request sethttpbody:data]; //set data post body     [request addvalue:[nsstring stringwithformat:@"%d",data.length] forhttpheaderfield:@"content-length"];      nsurlconnection *connection = [[nsurlconnection alloc] initwithrequest:request delegate:self];     if(!connection){         nslog(@"connection failed");     }  }` 

so nslog value null ,guide me how send value?????

  nsdata *jsondata = [nsjsonserialization datawithjsonobject:requestdatadict options:nsjsonwritingprettyprinted error:&error];       nslog(@"serverurl : %@", [serverurl absolutestring]);      nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl:serverurl];     [request sethttpmethod:@"post"];     [request sethttpbody:jsondata];      // create asynchronous connection     nsurlconnection * urlconnection = [[nsurlconnection alloc] initwithrequest:request delegate:self];     if (urlconnection)         self.responsedata = [[nsmutabledata alloc] init]; 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -