Archive for June 2011

A very nice open-source progress display

I found an awesome progress display that I have implemented in one of my iPhone apps. It is dead simple to use, does exactly what it should do and nothing more, and it is also open-source, which is good for developers on a budget like me.

This project by Matej Bukovinski is on github, here is the link:

MBProgressHUD

I found my way to this project through the awesome [iOS developer:tips]; web site, here is the link to their posting:

iOS Open Source : Heads Up Display with MBProgressHUD

BTW, Happy Birthday to Stanley Clarke. I have a ticket for when Return To Forever plays here in Columbus in August, I can’t wait.

Balance

Check out this code I was using for calculating text widths in my iPhone app’s PDF generator class (the first comment with the asterisks was added by me for this posting):

- (CGFloat)calculateTextWidth:(NSString *)text 
{ 
    // ********** do not use this method, see below for the fix **********
    CGSize fullSize = [UIScreen mainScreen].applicationFrame.size; 
    UIGraphicsBeginImageContext(fullSize);
    CGContextRef context = UIGraphicsGetCurrentContext();
 
    // calculate the text size
    CGContextSelectFont(context, [fontName UTF8String], fontSize, kCGEncodingMacRoman);
    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, -1.0));
    CGContextSetTextDrawingMode(context, kCGTextInvisible);
 
    // measure the text
    CGPoint initialTextPosition = CGContextGetTextPosition(context);
    CGContextShowTextAtPoint(context, 0, 0, [text cStringUsingEncoding:NSASCIIStringEncoding], text.length);
    CGPoint finalTextPosition = CGContextGetTextPosition(context);
 
    return finalTextPosition.x - initialTextPosition.x;
}

Pretty awesome, huh? Well, it worked awesome, my right justified text labels were all lining up great. The problem was that I could do one PDF in the app, maybe two, and the app would throw all kinds of memory warnings and then crash.

Well, as it turns out, it is a good idea to use a UIGraphicsEndImageContext() call when you use a UIGraphicsBeginImageContext() call. After I did this, all was right with the world.

Here is the finished product:

- (CGFloat)calculateTextWidth:(NSString *)text 
{ 
    CGSize fullSize = [UIScreen mainScreen].applicationFrame.size; 
    UIGraphicsBeginImageContext(fullSize);
    CGContextRef context = UIGraphicsGetCurrentContext();
 
    // calculate the text size
    CGContextSelectFont(context, [fontName UTF8String], fontSize, kCGEncodingMacRoman);
    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, -1.0));
    CGContextSetTextDrawingMode(context, kCGTextInvisible);
 
    // measure the text
    CGPoint initialTextPosition = CGContextGetTextPosition(context);
    CGContextShowTextAtPoint(context, 0, 0, [text cStringUsingEncoding:NSASCIIStringEncoding], text.length);
    CGPoint finalTextPosition = CGContextGetTextPosition(context);
 
    UIGraphicsEndImageContext();  // !!!!!
 
    return finalTextPosition.x - initialTextPosition.x;
}

BTW, Happy Birthday to Zuleikha Robinson. I miss the boys (and Yves, obviously) from The Lone Gunmen, I wish the show could have gone more than the 1/2 season it lasted.

How to Move Your App to the Cloud (CONDG meeting, June 23, 2011)

Brian Prince gave a presentation on Windows Azure at the Central Ohio .NET Developer Group meeting on June 23, 2011. The presentation was mostly talking the process of moving existing applications to Azure, and the pitfalls that can arise when doing so. It was a very interesting presentation, and very appropriate since the company I am now working at is looking at creating some cloud based services.

BTW, Happy 99th Birthday to Alan Turing. OK, he is not currently among the living, but Happy Birthday to him nonetheless.

iPhone/iOS development utilities

I have really been liking a couple of freeware iPhone, iPod touch, iPad, and iOS Simulator tools that I found. They both run great on my iMac, and are super simple to use, while providing some great missing functionality that the Xcode tools do not have.

The first is iExplorer from Macroplant, which allows you to spelunk through the file system of a device connected to your system. It works with stock devices as well as jailbroken devices. Here is the link to download this application:

iExplorer

The other tool is iOS-Simulator Cropper from Curious Times. This tool take screen shots from the iOS Simulator and, shockingly enough, automatically crops them down so that you can use them in your marketing materials or for uploading to the App Store. Here is the link to download this application:

iOS-Simulator Cropper (link redacted, URL not available)

EDIT: I changed the link to iExplorer (the application formerly known as iPhone Explorer), so the link above should not be broken any more.

Garage Band loop browser acting up

This is not so much a development issue as just a general usability issue, but it had frustrated me for a while and I am glad I got the issue behind me.

The problem was that my Garage Band v6 (2011 version) had some problems with the loops. When I would fire up the program, some of the loops in the loop browser showed up sort of grayed out with an arrow next to them. When I click on one of the grayed arrowed loops, I would get a message about how I needed to use Software Update to download the loops onto my computer. However, when I would go to Software Update, it would insist that there were no updates available. Also, when I went back into Garage Band to do the same thing again, it would respond with this message:

You have already initiated the installation of additional content for GarageBand via Software Update. For additional information please open the ‘Software Update’ application.

The battle of wits has begun.

Finally after trying to uninstall and reinstall a couple of times, and after looking through umpteen dozen posts on how this fixed it or that fixed it, I came upon this post on Apple’s web site:

Update the loop library (this link is dead as of 2/23/2012)

Finally I have slain the ROUS that was my loop browser issue.

EDIT:

The link above appears to be dead as of February 23, 2012, a quick Google search for “update the loop library” with specifying the site of apple.com yielded this link on Apple’s web site:

Update the loop library (http://support.apple.com/kb/PH1936) (this link is dead as of 1/8/2017)

I do not recall the exact contents of the now dead link, but from what I remember, I think that link and this one recommended very similar steps of actions.