gpt4 book ai didi

ios - 如何将特定委托(delegate)传递给 UIApplicationMain

转载 作者:行者123 更新时间:2023-11-29 01:32:29 25 4
gpt4 key购买 nike

我正在使用下一行在 iOS 上实例化我的应用程序并且一切正常,预计我不知道如何传递参数来实例化 MyAppDelegate

UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));

是否可以将 MyAppDelegate 的特定实例传递给 UIApplicationMain 或指定如何构造它?

最佳答案

根据 Apple Documentation :

int UIApplicationMain ( int argc, char * _Nonnull argv[], NSString *principalClassName, NSString *delegateClassName );

delegateClassName

The name of the class from which the application delegate is instantiated. If principalClassName designates a subclass of UIApplication, you may designate the subclass as the delegate; the subclass instance receives the application-delegate messages. Specify nil if you load the delegate object from your application’s main nib file.

使用 UIApplicationMain,您可以告诉 iOS 委托(delegate)类的名称。您的应用委托(delegate)负责管理系统与您的代码之间的高级交互。

因此,回答您的问题 - 不,我们确实/不能在 UIApplicationMain 中传递 AppDelegate 的特定实例。事实上,这是应用程序的入口点,到目前为止还没有实例化/加载任何东西。

我还建议您看看这个 nice blog讨论 iOS 应用启动周期。

关于ios - 如何将特定委托(delegate)传递给 UIApplicationMain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33314151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com