如何继承UIApplication而不是NSObject
我有 3 个 Xcode 项目,我想将它们集成到一个项目中。其中两个项目是基于视图的应用程序,因此应用程序委托继承了 NSObject 和 UIApplicationDelegate。但第三个项目不是基于视图的应用程序,因此应用程序委托继承了 UIApplication。
所以现在我陷入了困境。我应该如何整合它们三个,因为如果我尝试让我的第三个类继承 NSObject 则会出现很多错误。即使我处理这些错误,应用程序也会在运行时崩溃,出现异常:
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“只能有一个 UIApplication 实例。”
那我现在该怎么办?
I have three Xcode projects and I want to integrate them into one project. Two of those projects are view based application, hence the application delegate has inherited NSObject and UIApplicationDelegate. But the third project is not a view based application and so the app delegate has inherited UIApplication.
So now I am in a fix. How should I integrate the three of them, because if I try to make my third class inherit NSObject then there are many errors. And even if I deal with those errors, the app crashes during run time giving the exception:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
So what do I do now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该继承 UIApplicationDelegate,而应该实现 UIApplicationDelegate 协议。
例子:
You shouldn't be inheriting from UIApplicationDelegate, but instead implementing the UIApplicationDelegate protocol.
Example: