Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iphonejudy

macrumors 6502
Original poster
Sep 12, 2008
301
1
Hi,


I need to display a content of a website by passing a value.

my link is
http://www.xxx.com/xxx.aspx?country=code;

here i want to pass a code as a variable.(because code value is 100,101,102).According to the value the content will be changed.

HTML:
So i get a value of code in  a textfield and store it in a variable called code.

code=textfield.text; 


//To concatenate url with "code"

NSString *urlContents =	[NSString stringWithFormat:
				        @"http://www.xxx.com/xxx.aspx?country=? 
                                        %@",code ];

 urlContents having(http://www.xxx.com/xxx.aspx?country=100).

//To display Contents

 *NSString *urlContents1 = [NSString stringWithContentsOfURL:
				      [[NSURL alloc] initWithString:urlContents]];

 I use a textview to display a content, so ,

textview.text=urlContents1;

But i cannot get result.

Can anybody please give me the code.
Regards
judy
 

Pring

macrumors 6502
Sep 17, 2003
310
0
You need to provide more information about what's "not working". What have you tried so far to debug this?

Also don't use xxx.com as an example domain, it redirects to porn. http://www.example.com is reserved for the purpose of examples, use that.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
On first pass, I see a problem with your urlContents string creation.

Code:
NSString *urlContents =	[NSString stringWithFormat:
				        @"http://www.xxx.com/xxx.aspx?country=? 
                                        %@",code ];

What is with the "country=?" ? That is going to generate "country=?100", for example.

Try this instead:

Code:
NSString *urlContents =	[NSString stringWithFormat:
				        @"http://www.xxx.com/xxx.aspx?country=%@", 
                                        code ];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.