Ios ';NSInvalidArgumentException';关于UILocalNotification加载
从本地通知加载应用程序时,我试图读取其有效负载。为此,我有以下代码: AppDelegate.mIos ';NSInvalidArgumentException';关于UILocalNotification加载,ios,uilocalnotification,Ios,Uilocalnotification,从本地通知加载应用程序时,我试图读取其有效负载。为此,我有以下代码: AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Loading Stuff UILocalNotification *localNotif = [launchOptions objectForKey
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Loading Stuff
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
[(UITabBarController *)self.window.rootViewController setSelectedIndex:1];
UINavigationController *nav = [[(UITabBarController *)self.window.rootViewController viewControllers] objectAtIndex:1];
IMTRewardsViewController *rvc = [storyboard instantiateViewControllerWithIdentifier:@"rewardsView"];
[rvc loadPushNotification:localNotif];
[nav pushViewController:rvc animated:NO];
}
return YES;
}
IMTRewardsController.h:
-(NSDictionary *)loadPushNotification:(UILocalNotification *)notification;
IMTRewardsController.m:
- (NSDictionary *)loadPushNotification:(UILocalNotification *)notification
{
NSLog(@"%@",notification.userInfo);
return notification.userInfo;
}
从本地通知加载应用程序时,我收到以下错误:
<Error>: -[UIViewController loadPushNotification]: unrecognized selector sent to instance 0x14e70b30
<Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController loadPushNotification]: unrecognized selector sent to instance 0x14e70b30'
:-[UIViewController loadPushNotification]:无法识别的选择器已发送到实例0x14e70b30
:***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIViewController loadPushNotification]:未识别的选择器已发送到实例0x14e70b30”
您知道如何解决此问题并防止将来出现此问题吗?此错误表明您撤回的视图控制器只是一个UIViewController,而不是您期望的IMTRewardsViewController。您确定在情节提要中将自定义类属性设置为该类型吗?您可能需要先对其进行强制转换。情节提要返回UIViewController
IMTRewardsViewController *rvc = (IMTRewardsViewController *)[storyboard instantiateViewControllerWithIdentifier:@"rewardsView"];
a的儿子!这正是问题所在。谢谢,先生,没问题。这几乎每次都发生在我身上。