iosxcodensbundlemainbundle

NSBundle mainBundle not found


I'm using the split view template on the iPad.

In my MasterViewController the code:

NSBundle * bundle = [NSBundle mainBundle];

works.

In my DetailViewController the same code shows an error? I imported <UIKit/UIKit.h>. It knows NSBundle but does not recognize mainBundle for whatever reason.

Would be nice if so. could help me!

Error

Missing "[" at start of message send expression

EDIT

ANSWER:

I forgot the brackets. It's in a case-statement. So use:

case 1:
{
   //bla ...
}

Solution

  • In case statements if a variable is declared braces are required around the statement, this is just plain "C" syntax.

    Fixed:

    switch (sender.row) {
        case 1:
        {
            NSURL *movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"testclip" ofType:@"mov"]];
            MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
        }
    }
    

    I changed MoviePlayerController to MPMoviePlayerController assuming that is what the op meant. I also added the missing player variable.