Skip to content

Commit

Permalink
Scene delegate swizzling: don't crash when there is `UIScene.delegate…
Browse files Browse the repository at this point in the history
… == nil` (#4498) (#4499)
  • Loading branch information
maksymmalyhin authored and paulb777 committed Dec 13, 2019
1 parent a99f969 commit 20ab31f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ + (void)proxySceneDelegateIfNeeded:(UIScene *)scene {

// Skip proxying if the class has a prefix of kGULAppDelegatePrefix, which means it has been
// proxied before.
if ([className hasPrefix:kGULAppDelegatePrefix]) {
if (className == nil || [className hasPrefix:kGULAppDelegatePrefix]) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,14 @@ - (void)testAppDelegateIsProxiedIncludingAPNSMethodsWhenEnabled {

#if ((TARGET_OS_IOS || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000))

- (void)testProxySceneDelegateWithNoSceneDelegate {
if (@available(iOS 13, tvOS 13, *)) {
id mockSharedScene = OCMClassMock([UIScene class]);
OCMStub([mockSharedScene delegate]).andReturn(nil);
XCTAssertNoThrow([GULAppDelegateSwizzler proxySceneDelegateIfNeeded:mockSharedScene]);
}
}

- (void)testProxySceneDelegate {
if (@available(iOS 13, tvOS 13, *)) {
GULTestSceneDelegate *realSceneDelegate = [[GULTestSceneDelegate alloc] init];
Expand Down

0 comments on commit 20ab31f

Please sign in to comment.