Jac*_*own 20 iphone url objective-c uiwebview nsuserdefaults
我有一个应用程序存储NSUSERDEFAULTS中的用户ID和代码我需要使用这些值,以便让UIWebView访问url:www.mywebsite.com/check.php?id =(urhere)&code =(ifhere).
我已经看了一些其他主题,但到目前为止似乎没有任何帮助.
我是这种语言的新手,所以感谢您的耐心等待.
杰克布朗
Kar*_*hik 39
最简单的形式:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
Vis*_*ngh 10
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *userId= [prefs stringForKey:@"userIdkey"];
NSString *code= [prefs stringForKey:@"codeKey"];
Run Code Online (Sandbox Code Playgroud)
所以你的url字符串将是,
NSString *urlStr = [NSString stringWithFormat:@"http://www.mywebsite.com/check.php?id=%@&code=%@",userId,code];
Run Code Online (Sandbox Code Playgroud)