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

Nov 29

With the latest iPhone firmware update (2.2), Apple fixed several “security holes”, one of which broke KillExchangeLocks version 2.0.

The fix that broke things was CVE-ID: CVE-2008-4229

Impact: Restoring a device from backup may not re-enable the Passcode Lock

Description: The Passcode Lock feature is designed to prevent applications from being launched unless the correct passcode is entered. A race condition in the handling of device settings may cause the Passcode Lock to be removed when the device is restored from backup. This may allow a person with physical access to the device to launch applications without the passcode. This update addresses the issue by improving the system’s ability to recognize missing preferences. This issue does not affect systems prior to iPhone OS 2.0 or iPhone OS for iPod touch 2.0. Credit to Nolen Scaife for reporting this issue.

http://lists.apple.com/archives/security-announce/2008/Nov/msg00002.html

The key parts here is the resoultion, “This update addresses the issue by improving the system’s ability to recognize missing preferences”, and the person to blame is Nolen Scaife for reporting this issue. :-)

KillExchangeLocks version 3 does not implement the ideal solution as Apple has done a pretty good job on their fix. Instead of removing the passcode automatically like before, instead you now force the settings app to alow you to remove the passcode, as if you had setup a passcode without using Exchange.

This still times out every 24 hours like before, as Apple is actively querying the Exchange server every 24 hours to update and/or validate the security settings.

The up side is you should only have to run this part once, and you will always be able to remove the passcode.

Version 3 gives you the option if you want to modify your Auto Lock timeout.

The problem here is that the iPhone will over write any change if you go into the Settings app and click on the General tab (which shows your timeout setting).

Therefore this could need to be reset often, if you go into Settings -> General a lot.

I added some extra Time out levels for your convience.

You can now choose between: Never, 1 min, 2 min, 3 min, 4 min, 5 min, 10 min, 15 min, 20 min, 25 min, 30 min, 35 min, 40 min, 45 min, 50 min, 55 min, and 1 hour time out levels.

As I said before, this is by no means the ideal fix, but it is the only way I have found so far, and I figure this is better then having nothing.

If you really want a better fix in place, I would ask you to think about donating to this project as that would make it easier for me to work on this project then other paying projects. It is in no way required, but welcomed. If you wish to donate you can do so using PayPal.

KillExchangeLocks is available in Cydia under Utilities.

KillExchangeLocks 3

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

Sep 21

Desktop Remind is currently a featured download AND a staff pick on Apple.com’s downloads page!

http://www.apple.com/downloads/macosx/productivity_tools/

Sep 15

I am happy to announce a new Mac product called, Desktop Remind!

Desktop Remind embeds your calendar on your desktop, above your wallpaper but below your desktop items.

With Desktop Remind you can quickly and effortlessly now exactly what is on your calendar for the current day, and beyond.

Desktop Remind is user configurable, so you can place it exactly where you want on your desktop, and configure the font and font color to match your taste and/or wallpaper.

Desktop Remind also works with multi-monitor setups.

Feel free to give it a try for 14 days before a registration is required. A registration can be purchased for $4.99. Purchase here

Aug 31

I saw this in MacWorld and if you saw my post when I got my Mac Pro you will know that I think is SO true.

The Mac Pro is so sexy inside, unlike all other computers I have made or owned.