ios - when ever iam passing the values ..array inside the dictionary showing error from server database -


when ever iam passing values ..array inside dictionary showing error server database ...please 1 me if thers wrong in code .. iam getting error dis

officeprice: '(\n {\n officeprice = (\n {\n "amber_price" = 1;\n "amethyst_price" = 1;\n "cartage_price" = null;\n "cartage_price_type" = null;\n "credit_period" = 1;\n "diamond_price" = 1;\n "emerald_price" = null;\n "making_charge" = 1;\n office = 1;\n "ruby_price" = null;\n "sapphire_price" = 1;\n wastage = 1;\n "weight_by" = 1;\n }\n );\n }\n)', officecontactperson: '(\n {\n "contact_name" = kumar;\n designation = manager;\n },\n {\n "contact_name" = kumar;\n designation = manager;\n }\n)', officebank: '(\n {\n "account_name" = qwerty;\n "account_number" = 123456;\n "account_type" = 1;\n bank = 2;\n branch = bommanahalli;\n city = 1;\n "ifsc_code" = 12345;\n office = 1;\n }\n)', officedocument: '(\n {\n "document_original" = null;\n "document_stored_name" = null;\n office = 1;\n }\n)' } error (e_unknown) :: encountered unexpected error

nsstring *cityineger=self.txtcity.text; [cityineger intvalue]; nsstring *stateintegervalue=self.txtstate.text; [stateintegervalue intvalue];  nsstring *districtintegervalue=self.txtdistrict.text;  [districtintegervalue intvalue];      nsstring *post =[[nsstring alloc]initwithformat:@"name=%@&short_name=%@&shop_no=%@&door_no=%@&floor=%@&building=%@&street=%@&area=%@&main=%@&city=%@&state=%@&district=%@&pincode=%@&telephone=%@&contact_name=%@&designatio=%@&mobile=%@&email=%@&officeprice=%@&officecontactperson=%@&officebank=%@&officedocument=%@",self.txtshowroom.text,self.txtshortname.text,self.txtshop.text,self.txtdoor.text,self.txtfloor.text,self.txtbuilding.text,self.txtstreet.text,self.txtarea.text,self.txtmain.text,cityineger,stateintegervalue,districtintegervalue,self.txtpincode.text,self.txttel.text,self.txtname.text,self.txtdesign.text,self.txtmbl.text,self.txtemail.text,@[@{@"officeprice":@[@{@"office":@"1",@"making_charge":@"1",@"wastage":@"1",@"weight_by":@"1",@"credit_period":@"1",@"cartage_price_type":@"0",@"cartage_price":@"0",@"diamond_price":@"1",@"amethyst_price":@"1",@"amber_price":@"1",@"sapphire_price":@"1",@"emerald_price":@"0",@"ruby_price":@"0"}]}],@[@{@"contact_name" : @"kumar",@"designation" : @"manager"},@{@"contact_name" : @"kumar",@"designation" : @"manager"}],@[@{@"office":@"1",@"bank":@"2",@"branch":@"bommanahalli",@"city":@"1",@"account_type":@"1",@"ifsc_code":@"12345",@"account_number":@"123456",@"account_name":@"qwerty"}],@[@{@"office":@"1",@"document_original":@"0",@"document_stored_name":@"0"}]];      nslog(@"postdata :%@",post);       nsurl *url=[nsurl urlwithstring:@"http://139.59.252.34:1337/office"];     nsdata *postdata=[post datausingencoding:nsutf8stringencoding allowlossyconversion:yes];     nsstring *postlength=[nsstring stringwithformat:@"%lu",(unsigned long)[postdata length]];     nsmutableurlrequest *request= [[nsmutableurlrequest alloc]init];      [request seturl:url];     [request sethttpmethod:@"post"];     [request setvalue:postlength forhttpheaderfield:@"content-length"];     [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"];     [request sethttpbody:postdata];      nserror *error=[[nserror alloc]init];     nshttpurlresponse *response=nil;     nsdata *urldata=[nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error];  if (!urldata){       uialertview *alert =[[uialertview alloc]initwithtitle:@"error"message:fs_error_localized_description(error.code)                                                    delegate:nil                                           cancelbuttontitle:@"ok"                                            otherbuttontitles:nil];     [alert show];  } else {     nsstring *responsedata=[[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding];     nslog(@"response data ----->%@",responsedata);     nserror *error=nil;     nsdictionary *jsondata=[nsjsonserialization jsonobjectwithdata:urldata options:nsjsonreadingmutablecontainers error:&error];       nsarray *officecontact=[[nsarray alloc]initwitharray:[jsondata objectforkey:@"officecontactperson"]];     nslog(@"officecontact :%@",officecontact);      (int i=0; i<[officecontact count]; i++)     {         nsdictionary *contactname=[officecontact objectatindex:i];         nsstring *name=[contactname objectforkey:@"contact_name"];         [data addobject:name];         nsstring *design=[contactname objectforkey:@"designantion"];         [_dsgn addobject:design];     } } } 

you're building nsdictionary using @{} notation, , passing in-place nsstring string interpolation. string representation of nsdictionary isn't json format (starts example ().

since values officeprice=%@, officecontactperson=%@, officebank=%@ , officedocument=%@ static strings, why using string interpolation in first place?


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -