I have the following code that passes a URL to the destination controller which loads a url
StoreURLViewController.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"continueToStore"])
{
StoreWebViewController *controller = (StoreWebViewController *)segue.destinationViewController;
NSString *url = self.storeUrl.text;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:url forKey:@"storeUrl"];
[defaults synchronize];
controller.storeUrl = [StoreUrlViewController checkAndPrependProtocolForApiUrl:url];
NSLog(@"%@", controller.storeUrl);
}
}
I have the following code that checks to see if it has a url and loads a web view
StoreWebViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@",self.storeUrl);
if (self.storeUrl != nil)
{
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[StoreWebViewController checkAndPrependProtocolForUrl:self.storeUrl]]]];
self.webView.delegate = self;
}
}
On the simulator the URL is a string and loads the web page, but on the device it is nil and doesn't load the page.
Device Output for input http://google.com
2014-02-25 14:05:48.883 PHP Point Of Sale[2784:60b] (null)
2014-02-25 14:05:48.970 PHP Point Of Sale[2784:60b] (null)
Simulator Output for http://google.com
2014-02-25 14:09:10.703 PHP Point Of Sale[31811:70b] http://google.com
2014-02-25 14:09:10.775 PHP Point Of Sale[31811:70b] http://google.com