How to find your resources and how to generally find the directory layout

To find the main download directory for when you are receiving files, put this snippet of code in a test project or your main project at the point of opening:

 NSArray *pathsForDownloadedFiles = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *pathMain = [pathsForDownloadedFiles objectAtIndex:0];
 NSLog(@"main download directory is [%s]", [pathMain UTF8String]);

The first line lets you allow Apple to put the application download directory anywhere it likes. It will also be able to change it at will, without breaking your program.
The second line means that there is only one directory you need to access and its the first one. Remember in C arrays are zero based which means the first element of the array is at index number zero not at index number one.
NSLog will let you run the app in the simulator OR on your device and send logging information back to the debug console in XCode. Nice and integrated.

An alternative method:

 NSString *mainPath = [self getDataPath];

Uhhhhh yeah a bit shorter. Its not deprecated from what I see so one can use this method also.

Finally lets see where our resource is. Again, if you use this method, then XCode will be able to re-layout the resource directory structure anyway it wants without breaking your program. You KNOW they’re going to do this someday and they won’t tell you until its been done. So lets Program Defensively. Just like you drive defensively.
To find a specific resource that was compiled into your application:

 NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"mission1" ofType:@"jmf"];
 NSLog(@"Path for mission file is [%s]", [resourcePath UTF8String]);

The AT (@) sign is the NSString constructor without declaring an NSString. In case you’re wondering.

Good Luck and God’s Speed to ya mates.

NO JOY. An OS 3.0 upgrade story

Went to the iTunes store to upgrade one of my iPods to the OS 3.0 SDK to see if we can monetize the crap out of it. Hey, I’ve BEEN BUSY, so shutup.
Anyway, No joy. An UNKNOWN ERROR occurred on my transaction.
I will report back on this when I solve Apple’s problem (again).
Update and FIX:
The error was “An Unknown Error Occurred (1004)”. Continue reading


Face (our undead President) close your eyes and skip this rant.
Ok folks, spent the whole $25 in cheeseballs on the OS X upgrade.
Those *beep* *beep* *BEEPITY* *beeps* (edited by Face) at Apple have completly wiped my XCode links to the SDKs. NOTHING BUILDS NOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
HOLY **** Batman!
I’ll update here about this crap. GREAT! Like we need MORE WORK. Of course WE’LL be blamed for this. Those BEEEEEEeeeeeeeeeeeeeeeeeeeeep (edited by Face).
Ok my fault, when I upgraded, I should have put XCode 3.2 into A NEW PLACE!!! otherwise it “upgrades” your existing install (assuming you used the defaults) by erasing all your SDKs! How intuitive. Yeah if I RTFM. Ok so the way out is to download the OS 3.0 SDK which “doesn’t have all the 2.x SDKs”. Hmmm Let’s see nope. No more ranting. By this time you want answers.
I’m doing that right now and its taking 20 minutes for 404MB.
The original solution is to install the new 3.2 Xcode into A NEW PLACE and DO NOT UPGRADE the existing installation. Well they at least got that part correct.