ios - receiving signal: EXC_BAD_ACCESS in web service call function -
i'm new iphone development. i'm using xcode 4.2.
when click on save button, i'm getting values html page , web service processing them, , error:
program received signal: exc_bad_access
in web service call function. here code:
nsstring *val=[webviewobj stringbyevaluatingjavascriptfromstring:@"save()"]; nslog(@"return value:: %@",val); [adict setobject:[nsstring stringwithformat:@"%i",userid5] forkey:@"iuser_id" ]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:0] forkey:@"vimage_url"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:1] forkey:@"igenre_id"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:2] forkey:@"vtrack_name"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:3] forkey:@"valbum_name"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:4] forkey:@"vmusic_url"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:5] forkey:@"itrack_duration_min"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:6] forkey:@"itrack_duration_sec"]; [adict setobject:[[val componentsseparatedbystring:@","]objectatindex:7] forkey:@"vdescription"]; nslog(@"dict==%@",[adict description]); nsstring *url2= @"http://184.164.156.55/music/track.asmx/addtrack"; obj=[[urlcontroller alloc]init]; obj.url=url2; obj.inputparameters = adict; [obj webservicecall]; obj.delegate= self; //this function..it working many function calls -(void)webservicecall{ webdata = [[nsmutabledata alloc] init]; nsmutableurlrequest *urlrequest = [[ nsmutableurlrequest alloc ] initwithurl: [ nsurl urlwithstring: url ] ]; nsstring *httpbody = @""; for(id key in inputparameters) { if([httpbody length] == 0){ httpbody=[httpbody stringbyappendingformat:@"&%@=%@",key,[inputparameters valueforkey:key]]; } else{ httpbody=[httpbody stringbyappendingformat:@"&%@=%@",key,[inputparameters valueforkey:key]]; } } httpbody = [httpbody stringbyappendingformat:httpbody];//here getting exc_bad_access [urlrequest sethttpmethod: @"post" ]; [urlrequest sethttpbody:[httpbody datausingencoding:nsutf8stringencoding]]; [urlrequest setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; nsurlconnection *theconnection = [[nsurlconnection alloc] initwithrequest:urlrequest delegate:self]; }
can 1 me please?
thanks in advance
stringbyappendingformat
expects (sprintf-style) formatting string first argument, 1 more argument each % format placeholder. example:
[httpbody stringbyappendingformat:@"integer: %d, string: %@", 1234, @"hello"];
if httpbody
string happens contain '%' followed valid format type (e.g. 'd', 'f', '@', etc.), stringbyappendingformat
expect arguments, aren't supplying. attempting dereference arguments cause exc_bad_access.
i haven't followed code's logic right through, i'm not sure intended on line.
Comments
Post a Comment