tags:

views:

35

answers:

2

Hi, i developing an application in which i want to bind my own parameter with an URL for http post request. But i findout the serious problem during the string binding, The code snippet as follows:

NSString *mainURL1 = @"http://xxx.xxx.xx.xx/webservice/Service.asmx?op=UserDetailsNew?"; NSString *mainURL2 = [mainURL1 stringByAppendingString:@"MobileNo=%@",txtMobile.text]; NSString *mainURL3 = [mainURL2 stringByAppendingString:@"&Country=%@",txtCountry.text]; NSString *mainURL4 = [mainURL3 stringByAppendingString:@"&UserName=%@",txtName.text]; NSString *mainURL5 = [mainURL4 stringByAppendingString:@"&ScreenName=%@",txtScreenname.text]; NSString *mainURL6 = [mainURL5 stringByAppendingString:@"&EmailId=%@",txtemailid.text]; NSString *mainURL7 = [mainURL6 stringByAppendingString:@"&Password=%@",txtpassword.text]; NSString *mainURL8 = [mainURL7 stringByAppendingString:@"&RetypePassword=%@",txtretypepassword.text]; NSString *mainURL9 = [mainURL8 stringByAppendingString:@"%20HTTP/1.1"];

on binding the runtime arguments it ginev me too many parameter appending in NSString function.

how i solve above problem?

A: 

I'm not totally sure what you want to do, but it looks to me like you want to do a HTTP GET request, so check out NSURLConnection that will help you having it correctly formatted and executed

niklassaers
A: 

You should try using NSString stringWithFormat

Example NSString* url = [NSString stringWithFormat:@"http://xxx.xxx.xx/service.asmx?mobilenumber=%@&country=%@&region=%@",strNumber,strCountry,strRegion];

You can insert many strings into one string by using the %@ parameter.

Bharat Ahluwalia