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.

Droid will not assimilate you. Long live iOS.

TechCrunch is reporting that if you’re on iOS there is a 90% chance you have the latest OS version, but get this, if you are using droid, there is only four tenths of one percent chance (yes that’s correct) that you have the latest version of the Android Operating System.

We have talked about Droid fragmentation and holy smokes this underscores the mess that is called Droid. Continue reading