0

Recently i updated to the XCODE 11 and came to know the concepts of SceneDelegate and AppDelegate . This is my simple code for in AppDelegate :

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor yellowColor];
    return YES;
}

But unfortunately its getting crashed on the following line as shown in the Image:

enter image description here

And it shows the following error:

enter image description here

Please help me in resolving the issue which i am facing. Any help will be appreciated.

User1075
  • 819
  • 15
  • 36

2 Answers2

1

Assuming your root view controller's view is transparent, here is a place to setup UIWindow background color in your scenerio:

Modify in SceneDelegate.m the following callback as shown:

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    if (scene.class == UIWindowScene.class) {
        [[(UIWindowScene *) scene windows].firstObject setBackgroundColor:UIColor.yellowColor];
    }
}
Asperi
  • 228,894
  • 20
  • 464
  • 690
1

To Remove Screen Delegates:

Goto info.plist and remove the selected entry as shown below: enter image description here

Delete ScreenDelegate.h and ScreenDelegate.m from the project: enter image description here

Update your AppDelegate.h to:

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow * window;

@end

And finally, remove the Screen delegates from the AppDelegates class:

enter image description here

Hope that helps.

If you want to use ScreenDelegates you can refer the answer from Asperi

Mohit Kumar
  • 2,898
  • 3
  • 21
  • 34