简体   繁体   中英

AppDelegate valueForUndefinedKey

I am making an app in swift but I am facing some problems. I am trying to run my app but I get an error every time.

This is the full error : *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key currentUnityController.'

In the AppDelegate I use services like this:

@UIApplicationMain
final class AppDelegate: AppwiseCore.AppDelegate<Config> {
override var services: [ApplicationService] {
    return [
        UnityApplicationService(),
        FabricApplicationService(),
        KeyboardManagerApplicationService()
    ]
}
}

Then I call the UnityAppcontroller like this:

var window: UIWindow?

var application: UIApplication?
@objc var currentUnityController: UnityAppController!
var isUnityRunning = false

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    self.application = application
    unity_init(CommandLine.argc, CommandLine.unsafeArgv)
    currentUnityController = UnityAppController()
    currentUnityController.application(application, didFinishLaunchingWithOptions: launchOptions)

    startUnity()
    return true
}

And finally this is how I acces the app controller.

NS_INLINE UnityAppController* GetAppController()
{
NSObject<UIApplicationDelegate>* delegate = [UIApplication sharedApplication].delegate;
UnityAppController* currentUnityController = (UnityAppController*)[delegate valueForKey: @"currentUnityController"];
return currentUnityController;

}

Anny Help?

如果您的笔尖(xib文件)中有一个控件链接到视图控制器中的属性(IBOutlet)或方法(IBAction),并且您已删除或重命名了该属性或方法,则运行时将找不到它因为它已被重命名并因此崩溃。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM