Take the 2-minute tour ×

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.

share|improve this question

2 Answers 2

up vote 9 down vote accepted
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];
share|improve this answer
where userIdkey is the key you have used to store the userId and codeKey is what you used to store code –  iVishal Dec 16 '12 at 6:58
Thank you so much, i'm a new developer and this was so easy to understand! Thanks again :) all working :) –  Jack Brown Dec 16 '12 at 7:06
m gald it helped you..good luck..:)... –  iVishal Dec 16 '12 at 7:07

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];

share|improve this answer
Where abouts do I point to the variables located in nsuserdefaults? –  Jack Brown Dec 16 '12 at 5:51

Your Answer


