Home > front end >  NSInvalidArgumentException', reason: 'Configuration cannot be nil' while migrating fr
NSInvalidArgumentException', reason: 'Configuration cannot be nil' while migrating fr

Time:03-28

I can't seem to find out what is nil . The controller calling this WKWebView is not nil. There must be some type of configuration that I'm not setting. Any Ideas?

HelpViewViewController.h



#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>

@interface HelpViewViewController : UIViewController
< WKUIDelegate, WKNavigationDelegate>{}



@property (nonatomic, strong) IBOutlet WKWebView *webView;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *sidebarButton;

@property (assign) NSString *urlString;

@end

HelpViewViewController.m

#import "HelpViewViewController.h"
#import "SWRevealViewController.h"
#import "Functions.h"

@interface HelpViewViewController ()

@end

@implementation HelpViewViewController

@synthesize webView,urlString;

NSURL *urlToSave2 = nil;


- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@" start %@",urlString);

This NSLog never gets called. It is crashing before viewDidLoad is called.


    WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
    WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
    webView.navigationDelegate = self;
    NSURL *nsurl=[NSURL URLWithString:@"http://www.apple.com"];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webView loadRequest:nsrequest];
    [self.view addSubview:webView];

    
    NSLog(@" end %@",urlString);
}

CodePudding user response:

Although Apple documentation says that you can create a WKWebView as an outlet, I have not seen an example of that working. I suggest removing it from your xib/storyboard, making it a regular instance variable, and using your in-code initialization.

(In my case, this also required the addition of constraints when it was added as a subview.)

  • Related