20

I have an application that stores the user ID and code in NSUSERDEFAULTS I need to use these values in order to get UIWebView to visit url: www.mywebsite.com/check.php?id=(idhere)&code=(idhere).

I have looked at some other topics but nothing has seemed to help so far.

I'm new to this language so thanks for your patience.

Jack Brown.

Jack Brown
  • 580
  • 3
  • 6
  • 20

2 Answers2

39

Simplest form:

- (void) viewDidLoad 
{    
    [super viewDidLoad];

    UIWebView *webView = [UIWebView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:webView];
    NSString *url = @"http://google.com?get=something&...";
    NSURL *nsUrl = [NSURL URLWithString:url];
    NSURLRequest *request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];

    [webView loadRequest:request];
}
iOS Dev
  • 4,143
  • 5
  • 30
  • 58
Karthik
  • 1,386
  • 12
  • 7
10
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

NSString *userId= [prefs stringForKey:@"userIdkey"];


NSString *code= [prefs stringForKey:@"codeKey"];

and so your url string will be,

NSString *urlStr = [NSString stringWithFormat:@"http://www.mywebsite.com/check.php?id=%@&code=%@",userId,code];
Vishal Singh
  • 4,400
  • 4
  • 27
  • 43