objective c - Multiple UIPickerview in single UIViewController can't add soap response -
in application have 3 uipickerview , data added using soap web service,response getting ok can't add in picker view,i'm new objectives programming,please suggest me. here post code. - (void)viewdidload { [super viewdidload]; picker1 = [[uipickerview alloc] init]; [self.view addsubview:picker1]; _custompickerarray1 = [[nsmutablearray alloc] init]; [self dropdown]; } -(void)dropdown { nslog(@"dropdown method call"); nsstring *envalope=[nsstring stringwithformat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<soap:envelope xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "<soap:body>\n" "<value xmlns=\"http://tempuri.org/\">\n" “</value>\n" "</soap:body>\n" "</soap:envelope>"]; envalope=[nsstring stringwithformat:envalope]; nsdata *envelope = [envalope datausingencoding:nsutf8stringencoding]; nsstring *url = @“abc.asmx"; nsmutableurlrequest *request1 = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:url] cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:30.0]; } -(void) parser:(nsxmlparser *) parser didstartelement:(nsstring *) elementname namespaceuri:(nsstring *) namespaceuri qualifiedname:(nsstring *) qname attributes:(nsdictionary *)attributedict { if( [elementname isequaltostring:@“valueresult"]) { if (!soapresults) { soapresults = [[nsmutablestring alloc] init]; } elementfound = yes; } } -(void)parser:(nsxmlparser *) parser foundcharacters:(nsstring *)string { if (elementfound) { [soapresults appendstring: string]; nsarray * jsonarr =[nsjsonserialization jsonobjectwithdata:[string datausingencoding:nsutf8stringencoding] options:0 error:nil]; nslog(@"print array :%@",jsonarr); (nsdictionary * d in jsonarr) { if ([d objectforkey:@"clr"]!=[nsnull null]) { self.colorstring=[nsstring stringwithformat:@"%@",[d objectforkey:@"clr"]]; nslog(@"pvalue clr :%@",self.colorstring); [_custompickerarray1 addobject:self.colorstring]; nslog(@"pvalue after array fill:%d",_custompickerarray1.count); } else { self.colorstring=@""; } } } } - (int)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 3; } // number of rows of data - (int)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { if([pickerview tag]==1) { return _custompickerarray1.count; } else if([pickerview tag]==2) { return _custompickerarray1.count; }else if([pickerview tag]==3){ return _custompickerarray1.count; } } - (nsstring*)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { if([pickerview tag]==1) { return _custompickerarray1[row]; } else if([pickerview tag]==2) { return _custompickerarray1[row]; }else if([pickerview tag]==3){ return _custompickerarray1[row]; } } @end
first i'm declare 3 picker view in xib , set datasource , delegate, , in background soap web service call add data in pickerview ,but soap response getting soap response set in nsmutablearray not represent in picker view.
when response , parse through parser
write respective picker
reload method datasource
methods call , data fill in respective picker
.
[picker reloadallcomponents];
hope help.
Comments
Post a Comment