0

I make the following method call in my code:

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"myappname" withExtension:@"momd"];

When I run on the simulator, this returns an NSURL that works. When I run on my device, it returns an invalid CFStringRef. What am I doing wrong?

Another related question, my xcode project file is named like this: "MyApp", and the end of my bundle identifier is named like this: "myapp".

I have tried both ways and I get the same result, but I've read that the resource parameter string is case sensitive. Which one am I supposed to use?

Darren
  • 10,091
  • 18
  • 65
  • 108

1 Answers1

1

Try:

NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"YourModelName" ofType:@"momd"];
NSManagedObjectModel *objectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];
graver
  • 15,183
  • 4
  • 46
  • 62
  • Thank you. Actually I realized that I need to use the name of my model, which was written like this: "Myapp". I think that probably on the simulator the name is not case sensitive and on the device it is. – Darren May 22 '12 at 13:35