1

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 ...
}
DAS
  • 1,941
  • 2
  • 27
  • 38

2 Answers2

2

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.

zaph
  • 111,848
  • 21
  • 189
  • 228
0

You need to add curly braces inside the case's if you're going to declare new variables.

This code won't compile

case 1:
     NSURL *foo;

This will:

case 1:
{
    NSURL *foo;
}
Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102