Skip to content

Commit

Permalink
refactor: Remove outdated app init code from CDVAppDelegate
Browse files Browse the repository at this point in the history
The template's storyboard should handle the initialization of the view
controller, rather than constructing it manually here.
  • Loading branch information
dpogue committed Aug 15, 2024
1 parent 9b635b2 commit a3be849
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
23 changes: 0 additions & 23 deletions CordovaLib/Classes/Public/CDVAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,8 @@ - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:
return YES;
}

/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];

self.window = [[UIWindow alloc] initWithFrame:screenBounds];
self.window.autoresizesSubviews = YES;

// only set if not already set in subclass
if (self.viewController == nil) {
self.viewController = [[CDVViewController alloc] init];
}

// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
// self.viewController.startPage = @"index.html";

// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

return YES;
}

Expand Down
8 changes: 7 additions & 1 deletion tests/CordovaLibTests/CordovaLibApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ - (void)createViewController
// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.

self.window.rootViewController = _viewController;
_window.rootViewController = _viewController;
[_window makeKeyAndVisible];
}

- (void)destroyViewController
Expand All @@ -51,6 +52,11 @@ - (void)destroyViewController
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
BOOL retVal = [super application:application didFinishLaunchingWithOptions:launchOptions];

CGRect screenBounds = [[UIScreen mainScreen] bounds];
_window = [[UIWindow alloc] initWithFrame:screenBounds];
_window.autoresizesSubviews = YES;

// Create the main view on start-up only when not running unit tests.
if (!NSClassFromString(@"CDVWebViewTest")) {
[self createViewController];
Expand Down

0 comments on commit a3be849

Please sign in to comment.