PDA

View Full Version : Problem in accessing content of a web by passing variable




iphonejudy
Dec 11, 2008, 03:32 AM
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.

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
Dec 11, 2008, 05:27 AM
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
Dec 11, 2008, 10:15 AM
On first pass, I see a problem with your urlContents string creation.

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:

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

iphonejudy
Dec 12, 2008, 02:53 AM
Thanks.I finished