Search code examples
iphoneuiwebviewios6nsurl

NSURL Request not working


I am building an app that would run a website through my app. Basically the webView. I had no problems so far since the last xCode update. It basically runs with no errors but it does not work on iOs 6 simulator or device.

.h fle:

@interface ViewController : UIViewController{
    IBOutlet UIWebView *nView;
}

.m file:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL * myURL = [NSURL URLWithString:@"http://www.google.com"];

                     NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];

                     [nView loadRequest:myRequest];


}

If anyone can help I would be grateful. Thank you


Solution

  • I managed to get it working!

    .h file:

    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    
    @property (weak, nonatomic) IBOutlet UIWebView *myWebView;
    
    @end
    

    .m file:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSURL *url =[NSURL URLWithString:@"http://www.google.com"];
        NSURL*request = [NSURLRequest requestWithURL:url];
        [[self myWebView]loadRequest:request];
    }
    

    I included a property on h file and with some research I got the .m file working too. Although I got an issue saying:

    Incompatible pointer types sending 'NSURL *__strong' to parameter of type 'NSURLRequest *'

    Can anybody help to get rid of this issue as well please?