User1075
User1075

Reputation: 885

Project crashing at self.window line in Objective-C in Xcode 11

I have been using .storyboard file and corresponding .h and .m files to show a simple barcode scanner in my application.

What is the issue behind this?

Upvotes: 0

Views: 498

Answers (2)

Andrey Maksimkin
Andrey Maksimkin

Reputation: 183

I think you should use SceneDelegate class

@implementation SceneDelegate

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {

self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
UIViewController *vc = [[UIViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
}

Upvotes: 0

abanoub nabil
abanoub nabil

Reputation: 81

try creating new reference from UIWindow.

`- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect windowFrame = UIScreen.mainScreen.bounds;
UIWindow *theWindow = [[UIWindow alloc] initWithFrame:windowFrame];
UIViewController *viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
theWindow.rootViewController = viewController;
[self setWindow:theWindow];
return YES;

}

Upvotes: 1

Related Questions