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.

Popping up the keyboard on the iPlatform

If you want the virtual keyboard to popup when you display a text field in a view do the following:

In your viewDidLoad or if you call any method to do “things” before displaying then the variable that points to the text field should have the becomeFirstResponder message sent to it.
Example:
In the .h of your viewcontroller or class
UITextField *tfJoroto;

In the .m of your viewcontroller or class
-(void)viewDidLoad {
[tfJoroto becomeFirstResponder];
} // viewDidLoad

This should also set the focus to the UITextField.

Good hunting.
-T-

iPad Universal App

This is for the uninitiated and for posterity.
Running XCode 3.2.3.
Please NOTE: I had forgotten this. If you update the OS of your iPlatform device (pod/phone/pad) then you MUST update the XCode SDK. Now this makes sense in a way, however last night’s (8/13/10) update of the device was NOT matched by and Upgrade notification of the XCode SDK platform. I had to go a lookin. Bottom line is, unless you NEED something from that update, don’t do it in the middle of a project. It waste Humungo time. That means ALOT for you marketing weasels.

1) Create a View Based app
2) Name it of course.
3) Drop down the targets folder in the project explorer. Continue reading

iPad – The Conqueror

I went to Best Buy and they had the requisite four iPads to touch and feel and play with. Lots of kids/teens/college age. They were all over everything, the macbooks, iPads, everything that was there. It was “an event” for them. The fun they were having, the giggling, “makes” the sale as much as the device. It was like watching one the “cool, hip” commercials. Continue reading

iPad – uh yeah great name

Open letter to Mr. Steven Jobs:

Steve,
This isn’t a pile on session, I’ve seen the ignorant bashing you incessantly.   I’m too tired). I’m not here to do the same.  Well of course I am. Its fun, its the NEW new thing to bash Apple for not providing everyone their own personal spaceship to Mars (see previous blog post).
iPad: This name, sucks. Continue reading