Dec 28

If you have ever wanted to use a Indeterminate Spinner NSProgressIndicator on a dark background you have probably been upset to find that there is no way to get a white spinner.
That is where WhiteIntermProgIndicator comes into play.
WhiteIntermProgIndicator, is based off of AMIndeterminateProgressIndicatorCell by Andreas at Harmless Cocoa.

Screenshot:
whiteintermprogindicator

Download: WhiteIntermProgIndicator.zip

Dec 27

If you have an application that allows users to upload content to the app, you might want to show the user how much space is available for them to use.

This is especially true on the iPhone where it is not as easy for the user to quickly check if they have enough room to upload a given file.

You may also want to check if there is enough space before you start the upload, so you can inform them that the file wont fit.

That brings you to the task of figuring out how much free space there is, and more importantly how much free space is left that you as an unprivileged program can access.

The following code is based towards the iPhone, however all that would be needed to change it to be used on the Mac is the location you are checking for free space, and the setting of the label.

NOTE: The below “shown” code is old. The updated code is in the zip file at the bottom

#include <sys/param.h>
#include <sys/mount.h>
NSString *sizeType;
 
float availableDisk;
 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 
struct statfs tStats;
 
statfs([[paths lastObject] cString], &tStats);
 
availableDisk = (float)(tStats.f_bavail * tStats.f_bsize);
 
if (availableDisk > 1024)
{
	//Kilobytes
	availableDisk = availableDisk / 1024;
 
	sizeType = @" KB";
}
 
if (availableDisk > 1024)
{
	//Megabytes
	availableDisk = availableDisk / 1024;
 
	sizeType = @" MB";
}
 
if (availableDisk > 1024)
{
	//Gigabytes
	availableDisk = availableDisk / 1024;
 
	sizeType = @" GB";
}
 
diskSpaceLbl.text = [[@"Available Disk Space: " stringByAppendingFormat:@"%.2f", availableDisk] stringByAppendingString:sizeType];

This will give you something like the following:

availablediskspace

UPDATE:
I have gone a step further and made this into an easy to use class, that works out of the box with the iPhone and the Mac.

FSStats.zip

Dec 04

Last night I gave a presentation at the Phoenix iPhone Developers Group (Pi) on SQLite.

I am posting the presentation and sample code here for anyone who is interested.

Please note that this is by no means the “proper” or only way of doing things. This is simply one way of doing it, and is for reference purposes only. The code uses the FMDB SQLite Wrapper.

Example Code: (example.zip)

Keynote Presentation (sqlite-presentation.zip)

Oct 26

I am proud to introduce NSCoder Night for Phoenix.

If you haven’t heard of NSCoder Night, here is a brief intro (partially borrowed from the website)

NSCoder Night is a weekly event where Cocoa developers come together for some coding and camaraderie in the relaxed atmosphere of a coffee shop or pub with a wireless network.
Unlike more formal meetings like CocoaHeads there is no presentation, just hanging out with other (similar interest) geeks and working on your own projects or group projects. It is a great way to gain a IRL (in real life) friendship with other developers, as well as getting help on something you are stuck on.

It is kind of similar to how we go somewhere after XCodePhoenix meetings, but with your laptops and more frequently.

As there is no presentation it is a low key come and leave as you need type of meet-up.
If you can’t make it one week, thats ok, make it the next week.

The Phoenix chapter of NSCoder Night will be meeting Tuesdays at 7pm at Coffee Rush @ Gilbert and Baseline in Gilbert.

Fell free to to tell all your dev friends and we hope to see you there.

Sep 30

In Mac OS X 10.5 Apple added a new set of API’s for adding an application to the users login items in Cocoa.

In looking for the way to use this new API, I stumbled upon Justin Williams’ blog carpeaqua.com where Justin was nice enough to put together a code example project showing just how to use this new API.

You can grab the sample project at his public code repository http://secondgear-public.googlecode.com/svn/trunk/SGLaunchAtLogin/

Thanks again to Justin for making this available.

Hopefully this page helps with his Google position for people searching for this info.

Read his full post at: http://log.carpeaqua.com/post/27727810/adding-an-application-to-login-items-in-mac-os-x