views:

27

answers:

2

Hi, I have a UIWebView that loads a link, http://www.google.com/a/datacommsales.net. But I want to have the datacommsales.net part interchangable. What I would like it to be is http://www.google.com/a/stringOne, stringOne being the NSString, so I can set the value of the string and change the link without editing the code. But the link is inside quotes, @"http://www.google.com/a/datacommsales.net", so it doesn't recognize the string. How could I include the string's value as part of the link? Any help is appreciated.

EDIT

To be a little more specific, here's my code:

- (IBAction)refreshNow:(id)sender

{

NSString *variablePart = @"secondpart.com";
NSString *page = [NSString stringWithFormat:@"google.com/a/variablePart/docs"];

[webView loadHTMLString:page baseURL:nil];

}

How would I put the string variablePart in the link like that?

+1  A: 

Checks the NSString stringWithFormat method... Or explain a little more how you do your stuff...

Macmade
+1  A: 

do you mean just something like

NSString *variablePart = @"secondpart.com";
NSString *url = [@"http://www.google.com/" stringByAppendingString:variablePart];

EDIT:

NSString *variablePart = @"secondpart.com";
[NSString stringWithFormat:@"google.com/a/%@/docs", variablePart];
Jack
Thanks. Kind of what I'm looking for. But to be a little more specific, here's my code:- (IBAction)refreshNow:(id)sender{ NSString *variablePart = @"secondpart.com"; NSString *page = [NSString stringWithFormat:@"google.com/a/variablePart/docs"]; [webView loadHTMLString:page baseURL:nil];How would I put the string variablePart in the link like that?
MN
Thanks! Perfect!
MN