Domanda

I've created a command line application through xcode with core data. But when I do this:

NSString* dataPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"json"];

dataPath is always nil. I have a file next to the main.m file called test.json and I have added it to the Build Phrases -> Copy Files section. It is next to main.m also in Finder.

I'm using OSX Mavericks and xcode 5. Thanks in advance!

È stato utile?

Soluzione

I found it out after some fiddling. Apparently you have to check not only Products Directory in the Copy Files section, you also have to un-check Copy only when installing, also take care of the subpath, so you don't miss that.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top