Reputation: 337
I create settings bundle, i add a text field in it, and i need to load url from it to uiwebview. I want to add Default Value for it, but it doesn't loading in uiwebview, after changing it loads.
Help please!
<dict>
<key>KeyboardType</key>
<string>URL</string>
<key>DefaultValue</key>
<string>http://iscientist.ru/</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Домашняя страничка 1</string>
<key>Key</key>
<string>url1</string>
</dict>
<dict>
<key>KeyboardType</key>
<string>URL</string>
<key>DefaultValue</key>
<string>http://google.com/</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Домашняя страничка 2</string>
<key>Key</key>
<string>url2</string>
</dict>
and the code:
NSString *settingValue1 = [[NSUserDefaults standardUserDefaults] stringForKey:@"url1"];
NSURL *urlx1 = [NSURL URLWithString:[NSString stringWithFormat:@"%@", settingValue1]];
NSURLRequest *request1 = [NSURLRequest requestWithURL:urlx1];
[_webView loadRequest:request1];
NSString *settingValue2 = [[NSUserDefaults standardUserDefaults] stringForKey:@"url2"];
NSURL *urlx2 = [NSURL URLWithString:[NSString stringWithFormat:@"%@", settingValue2]];
NSURLRequest *request2 = [NSURLRequest requestWithURL:urlx2];
[webView2 loadRequest:request2];
Upvotes: 1
Views: 627
Reputation: 89509
The key you're using to fetch the default URL is wrong, nik.
Instead of
NSString *settingValue1 =
[[NSUserDefaults standardUserDefaults] stringForKey:@"url1"];
Use this:
NSString *settingValue1 =
[[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultValue"];
and that will return the http://iscientist.ru/
URL you're trying to load.
Upvotes: 1