From 19895945c2913695f0af12e1f1d6c8ce78c4efa0 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Fri, 14 Dec 2018 05:31:26 -0600 Subject: [PATCH] fix(ios delegate) Eliminate crash on selector looking for "Window" (#6428) * Add a "window" value so that NS doesn't crash on selectors looking for the delegate.window... * chore: tslint * chore: comments to referenced issues added --- .../application/application.ios.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index b08dbabf4..867f2ef6f 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -21,9 +21,20 @@ import { Frame, NavigationEntry } from "../ui/frame"; import * as utils from "../utils/utils"; import { profile, level as profilingLevel, Level } from "../profiling"; -class Responder extends UIResponder { - // -} +// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430 +// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved: +// https://github.com/NativeScript/ios-runtime/issues/1012 +var Responder = (UIResponder).extend({ + get window() { + return iosApp ? iosApp.window : undefined; + }, + set window(setWindow) { + // NOOP + } +}, { + protocols: [UIApplicationDelegate] + } +); class NotificationObserver extends NSObject { private _onReceiveCallback: (notification: NSNotification) => void; @@ -150,7 +161,7 @@ class IOSApplication implements IOSApplicationDefinition { this.setWindowContent(args.root); } else { this._window = UIApplication.sharedApplication.delegate.window; - } + } } @profile @@ -368,4 +379,4 @@ global.__onLiveSync = function () { } livesync(); -} \ No newline at end of file +}