Velkyr
Velkyr

Reputation: 373

Xcode: Multiple directories and subdirectories

I'm trying to figure out how to get all of my map tiles into XCode, so that I can call them like:

/0/0/0.png

/1/0/1.png

... etc

Hasn't seemed to work so far, so I was wondering if anyone could advise on how to do so.

Upvotes: 0

Views: 572

Answers (2)

Kreiri
Kreiri

Reputation: 7850

When adding resources to Xcode, if you select "create folder references for any added folder", then Xcode will preserve hierarchic structure when copying these folders to bundle. Referenced folders have blue folder icons in project navigator.

A downside to this approach is that Xcode doesn't watch changes of files in referenced folders, so if you change an already added file, you'll have to do a clean build or the app bundle will have an old version of the file.

Upvotes: 2

Ismael
Ismael

Reputation: 3937

When you build your XCode project, all resources are copied directly to your application's bundle, so if you have several images named the same (even if they are in different directories), only one will be taken and the rest will be ignored / overwritten.

If you have something like 0/0/0.png, 1/0/0.png I'm sorry for what I have to tell you, but you will have to rename your tiles to something like 000.png, 100.png and so on.

Also, to get an image that you added in your project, you get it by name, like this:

UIImage *tileImage = [UIImage imageNamed:@"000.png"];

Upvotes: 1

Related Questions