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.
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.

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

Gruber is not completely correct about Apple’s policy change

This post was sent to me about Gruber’s analysis of the new Apple policy (3.3.1) that stated that developers were not allowed to use third party development tools that could target multiple mobile phone platforms. We were looking into these currently and I have to say I’m quite miffed. Continue reading

aGauge now available for iPhone & iPod

aGauge is now available for the iPod and iPhone! Test your accelerometer with this utility. Super Cool!


Or visit the Joroto iTunes Store:

iPod/iPhone “No provisioned device” error in XCode

In the Organizer in XCode you notice that your iPlatform device (iPod/iPhone) is not recognized as a provisioned device. The little “light” is not green. However iTunes can sync with it and give it a great big kiss.
Cause: I believe this is due to the iPlatform device being plugged in when the computer goes to sleep.
1) Unplug the iPlatform device from the USB.
2) Hold down the top power off and the circle App Exit button at the same time, then release at the same time.
3) A slide switch appears saying “Power off”. Do so. This is a hard power down of the device.
4) Now you can just plug the device back into the USB cable. XCode will see it and use it now. This has happened many times to me and this is the exact solution to that.