简体   繁体   English

IOS中didFinishLaunchingWithOptions中的错误-Objective-C应用开发

[英]Error in didFinishLaunchingWithOptions in IOS - objective-c app development

In my 'didFinishLaunchingWithOptions' function i am giving following line at the end :- 在我的'didFinishLaunchingWithOptions'函数中,我在末尾给出以下行:-

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
    return [super application:application didFinishLaunchingWithOptions:launchOptions]; 

But it is giving the following warning:- 但是它发出以下警告:

'NSObject' may not respond to 'application:didFinishLaunchingWithOptions' function 

And when i build it, the application terminates with 'Uncaught Exception error' 当我构建它时,该应用程序终止并显示“未捕获的异常错误”

Can anybody suggest why this is happening. 谁能说明为什么会这样。 Thanks 谢谢

Try 尝试

[self application:application didFinishLaunchingWithOptions:launchOptions];

Base objct like NSObject dont implement method of didFinishLaunchingWithOptions:launchOptions 像NSObject这样的基本didFinishLaunchingWithOptions:launchOptions不实现didFinishLaunchingWithOptions:launchOptions方法

you should return YES at the end of didFinishLaunchingWithOptions:launchOptions 您应该在didFinishLaunchingWithOptions:launchOptions的末尾返回YES

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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