开发者

Xcode not finding directory within resources group

Xcode will not seem to recognize a particular directory of files in the Resources group. This is how I'm retrieving the folder:

NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Tiles"];

And this is the error that I get:

2011-03-06 17:52:47.660 [*removed*][36648:207] Could not locate any tiles at /Users/j开发者_StackOverflow中文版ames/Library/Application Support/iPhone Simulator/4.2/Applications/909785DD-B3E8-41CB-A3D9-C19D1826C448/[*removed*].app/Tiles

I checked, and sure enough that directory does not exist. But it does exist in the project directory.

I have done the following:

  • Deleted the app off of the simulator
  • Deleted the "Tiles" folder from the actual app directory and from within the Resources group in Xcode
  • Cleaned all targets
  • Dragged the "Tiles" folder from another location directly into the "Resources" group in Xcode and told it to copy into the directory


File groups in XCode don't necessarily translate to folders inside your compiled application bundle.

Try using this alternate method for accessing your application resources:

[[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"txt"]; 

Note that you don't have to specify where your MyFile.txt file actually is -- as long as it exists in your project as a resource, it will be found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜