本文介绍了如何将UIApplication子类化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
iPhone Reference Libary - UIApplication说我可以继承UIApplication,但如果我尝试这个,我会得到一个例外:
The iPhone Reference Libary - UIApplication says I can subclass UIApplication, but if I try this I will get an exception:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
这让我想起了Highlander只有一个,。: - )
This reminds me of the Highlander "There can be only one,. :-)
我是否必须将其他争论传递给UIApplicationMain?或者我是否错过了在libary中有什么东西?
Do I have to pass other argurments to UIApplicationMain? Or did I missread somthing in the libary?
推荐答案
您是否已将子类的名称传递给UIApplicationMain?我们假设您已经
Did you pass the name of your subclass to UIApplicationMain? Let's assume you have
@interface MyUIApp : UIApplication
...
然后在main()中你应该这样做:
then in main() you should do:
NSString* appClass = @"MyUIApp";
NSString* delegateClass = nil;
int retVal = UIApplicationMain(argc, argv, appClass, delegateClass);
这篇关于如何将UIApplication子类化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!