0

I get the following error after I change the rootViewControler of my UIWindow.

2012-10-16 15:12:35.653 repdocApp[22898:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914'

The strange thing is, it only occurs if I have a line in my code which will never be executed at this time.

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{   
    AppDelegate *app = (AppDelegate *) [[UIApplication sharedApplication] delegate];
    OverviewModel *model = [self.dataArray objectAtIndex:indexPath.row];

if (model.modelType == ModelTypeCatalog)
{
     NSLog(@"HERE");
    if (app.window.rootViewController == app.catalogViewController)
    {
        return;
    }
    // with this return no error but this branch is never executed
    // return;
    [UIView transitionFromView:app.window.rootViewController.view
                        toView:app.catalogViewController.view
                      duration:0.45f
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    completion:^(BOOL finished){
                        app.window.rootViewController = app.catalogViewController;
                    }];
}
else
{
    if (app.window.rootViewController == app.catalogViewController)
    {
        [app.navigationPopoverController dismissPopoverAnimated:NO];
        [UIView transitionFromView:app.window.rootViewController.view
                            toView:app.splitViewController.view
                          duration:0.45f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        completion:^(BOOL finished){
                            app.window.rootViewController = app.splitViewController;
                        }];
    }
}

}

I search the whole internet but I found nothing about +[NSNotificationCenter dictationViewClass] or what this can be.

EDIT: I notice now, it only happens if I change the rootViewController in a transition, if I do it directly no error happens.

Sebastian
  • 952
  • 1
  • 14
  • 41

3 Answers3

1

Your Error Log is 2012-10-16 15:12:35.653 repdocApp[22898:c07] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914

You are calling wrong method .dictationViewClass does not exist in ios. It's Simply mean you are trying to call a methods which is not exist for Corresponding Class (NSNotificationCenter). You should Change set Notification as below

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourMethodWantToExcute:) name:@"NSNotificationName" object:nil];

I hope It'll be helpful to You.

Kamar Shad
  • 6,089
  • 1
  • 29
  • 56
  • Hi, the problem is nowhere in the code (my or frameworks) is something with that name and why it only happens when I remove a return in a branch that never get executed? – Sebastian Oct 16 '12 at 13:38
  • @Sebastian actually you are registering the NSNotification in wrong way that method(`dictationViewClass`) does not exit for `NSNotificationCenter` Class That's Why you are getting Exception. just replace `dictationViewClass` with `defaultCenter`. For more About how to set Notification https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html – Kamar Shad Oct 16 '12 at 13:43
  • The problem is there is nothing like this in my code or any framework I use. – Sebastian Oct 16 '12 at 13:52
  • @Sebastian see your error log.2012-10-16 15:12:35.653 repdocApp[22898:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSNotificationCenter dictationViewClass]: unrecognized selector sent to class 0x1d63914' – Kamar Shad Oct 16 '12 at 13:55
  • I search for it and found nothing and on the other hand why the error dont show up when I add the return? (but this line get never executed anyway) – Sebastian Oct 16 '12 at 13:56
  • @Sebastian ok , can you share your existing code with me?so that i can figure out the exact problem. – Kamar Shad Oct 16 '12 at 14:13
  • I solve the problem with another solution, the main problem seems to be the change of the rootviewcontroller. Sorry I don't have a test project with the error. – Sebastian Oct 18 '12 at 06:00
0

unrecognized selector sent to class means that there is no such method defined for this class. Try:

  1. Delete the line and try if it works.
  2. Look for a category withn your sources if it contains this method
  3. Write your own blank method with the same name
  4. Try to figure ouy what this method meant to do and implement it
pro_metedor
  • 1,176
  • 10
  • 17
0

Its not a real answer on this but the same error happens on different actions again regardless of an animation. The problem seems to be the change of the rootviewcontroller, I replace that with a hidden tabbarcontroller and switch between the tabs and the problem is gone.

Sebastian
  • 952
  • 1
  • 14
  • 41