The darned 3rd map-file

Member
Posts: 95
Joined: 2009.09
Post: #1
Hey,

I load map's from my boundle with the code:

Code:
    NSString* path = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"map%i.plist",mapNr]];

and I have the *.plist files:
map1.plist
map2.plist
map3.plist
map4.plist

Well now in the simulator everything works fine.
On the Iphone though, map3.plist will not be loaded, instead I get a very empty file.
Even if I delete map3.plist, change the "4" in map4.plist to a "3" (they have the same content till now) I get the same error when loading nr3.
If I change the 3 back to 4 , map4.plist is loaded fine again.

I'm going nuts here, help me pleeeease!

EDIT:
Alternatively tried:
Code:
    NSString* path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"map%i",mapNr] ofType:@"plist"];
same result
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #2
What happens if you do NSLog([NSString stringWithFormat:@"map%i",mapNr]); right under the line where you try to load it? What's the output?
Quote this message in a reply
Member
Posts: 95
Joined: 2009.09
Post: #3
Console-Output:
Code:
2009-11-11 11:43:46.168 Tactica[1186:207] map2.plist
2009-11-11 11:43:46.174 Tactica[1186:207] ----> Initiated Map with Map: /var/mobile/Applications/6A1E437F-54B1-4D39-A165-81C9D900D55C/Tactica.app/map2.plist
[...]
2009-11-11 11:45:07.074 Tactica[1186:207] map3.plist
2009-11-11 11:45:07.091 Tactica[1186:207] ----> Initiated Map with Map: (null)

for the code:
Code:
NSString* path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"map%i",mapNr] ofType:@"plist"];
NSLog([NSString stringWithFormat:@"map%i.plist",mapNr]);
[...]
NSLog(@"----> Initiated Map with Map: %@",path);

Again, if I start the same project in the simulator all maps load without errors. I think the file "map3.plist" must have been omitted when transfering it to the Iphone, because the code itself seems to be flawless. Yet map3.plist is exactly the same as "map4.plist" the other maps except for the "3" in its title.
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #4
Weird. Did you show package contents on the app to see if it's at least included in the bundle?
Quote this message in a reply
Member
Posts: 95
Joined: 2009.09
Post: #5
Well I got it!

In the Product's "Show Package Contents" the file was capitalized.
I.e. there was a "Map3.plist" in the File tactica.app that I could only see when clicking "Reveal in Finder".
In the Project Details in Xcode the file was "map3.plist" and also in the project folder if I opened it in Xcode.

I tried to delete the product file and build a completely new one, "build clean" etc. and at some point the "Map3.plist" was finally gone from the product app.
Maybe it was capitalized in the beginning and the Mac doesn't care for Capitalization, so he thought that he didn't have to update "Map3.plist" with "map3.plist" when I was building a file. He seems to update only the files that changed.
But on the Iphone of course , capitalization is important.
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #6
Ah right, I forgot about that little detail too. Glad you got it! Smile
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #7
This has to do with how your filesystem is formatted. If you look in Disk Utility, you'll see that you can format your Mac's hard drive to be case sensitive too if you wish. As you experienced, the iPhone's filesystem is always set to be case sensitive, which seems to trip up quite a few developers...
Quote this message in a reply
Member
Posts: 95
Joined: 2009.09
Post: #8
Well I knew the IPhone is case-sensitive.
The Problem is that I thought all the files I could see in xcode or finder where lower-case.
It's just that in the built app the *.plist seem not to be updated as long as you don't rename the plists.
Now I even understand problems I had some time before, where I had to build numerous times before changes in a map resulted in the program actually showing the changes,
Quote this message in a reply
Post Reply