January 2009

42

Another birthday has passed. It has been an eventful year: I got married, and I've become part of a new family.

My wife Pebble is the most amazing person I've ever met. She's smart. She's kind. She's giving. She's forgiving. Most of all, she's open in a way I thought nobody could be. Marriage and life aren't always wonderful, but she's a wonderful wife, and I know I've chosen the right partner. We grow closer every day, and I honestly can't remember what my life was like before I met her. (I'm pretty sure it sucked.)

For my birthday, she bought me the complete collection of Planet of the Apes movies on Blu-ray. I didn't even ask for it. How cool is that?

My stepson Bailey is about to become ten years old. Like his mother, his emotions and thoughts are always right at the surface, so I always know where I stand with him. He is sometimes incredibly cute, and other times he's apparently possessed by Satan, but I know we'll always love one another. He loves his new grandma and grandpa (my parents), and enjoys spending time with his new cousins (my nieces).

We also got a puppy. He's a Yorkshire Terrier named Mouse, and he thinks he owns the house. I believe there is nothing cuter than a Yorkie puppy.

Our little cabin in the woods is nice, but we all agree that we'd like more space, and we're all getting tired of driving two hours a day to get to and from our occupations, so we're probably going to be moving closer to Atlanta some time this year. But we're not in a hurry: we do like our little cabin in the woods.

My forties are shaping up to be a lot better than my twenties and thirties were. Life is good. (But I occasionally complain about it anyway.)

I've done more traveling in the past year than any other. My wife and I went to Waikiki for our honeymoon, and also visited Pensacola and the Grand Canyon. I went alone to Australia for three weeks on business, finally putting my passport to use.

Career-wise, I'm in a bit of a rut. I had hoped to do some job searching this year, but with the economy the way it is, I consider myself fortunate to have the contracting gig that I have. I'll try to acquire some new skills this year. Maybe next year...

Saving a View as a Photo in an iPhone App

For an iPhone app that I'm working on, I want to be able to save the screen image to the Photos album. My first attempt at this was complicated: I created a color space, a bitmap context, a CGImage, and finally a UIImage, copying and pasting most of the code from the Quartz 2D Programming Guide. Unfortunately, it didn't work; I kept getting BAD_ACCESS signals when I called UIImageWriteToSavedPhotosAlbum(), even though it looked to me like everything was correct.

After Googling for a bit for known issues with UIImageWriteToSavedPhotosAlbum, I ran across a far easier solution to the problem. Here are the methods I ended up with:

// Create an image for the view and save it to the Photos library
- (void)savePhotoOfView:(UIView *)view
{
    UIGraphicsBeginImageContext(view.bounds.size);
    [view drawRect:view.bounds];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIImageWriteToSavedPhotosAlbum(image,
                                   self,
                                   @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:),
                                   NULL);
}

// Called by UIImageWriteToSavedPhotosAlbum() when it completes
- (void)   savedPhotoImage:(UIImage *)image
  didFinishSavingWithError:(NSError *)error
               contextInfo:(void *)contextInfo
{    
    NSString *message = @"This image has been saved to your Photos album";
    if (error) {
        message = [error localizedDescription];
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
}

These just call the view's drawRect method to create an image, save the image to the Photos library, and then pop up an alert box to let the user know what happened.

iPhone Development Fun

I am so thankful for the existence of the iPhone. Twenty years ago, if you'd told me I'd be holding a pocket-sized computer that had a high-resolution touchscreen, a wireless always-on connection to the Internet, and a library of Hollywood movies, I wouldn't have believed it. The fact that it can make phone calls is nice too, but I frankly don't care too much about that feature. All those idiots who keep asking "Why would anyone spend $500 on a phone?!?" are really missing the point.

(See The iPhone is a piece of shit, and so is your face for an alternative opinion.)

Writing little apps for the iPhone is the only thing keeping me from giving up on software completely. (Well, OK, I guess the mortgage has something to do with that also.) At work, I'm starting my third year of maintaining a horrible soul-crushing legacy application, and it's hard for me to maintain the appropriate level of Give-a-Shit. Playing with the iPhone SDK helps.

I'm working on an application now that I hope to put in the App Store in a few weeks. No, it's not my to-do list app. I'd rather not write about it yet, because it is the kind of thing someone else could create during an uninterrupted weekend, but once it's done, I'll start the marketing.

My first app, JacksOrBetter, has not been wildly successful. I've sold about 200 copies worldwide. That's not surprising, as it's a simple game, and there are a few dozen other casino-style card games available in the App Store, many of which are free. I didn't expect to make money with that game; I just wanted to go through the process of developing something and putting it up for sale.

I doubt my next app will bring in a windfall either, but that's fine with me. I'm having fun, and people are using software I've written. That's why I got into this business in the first place.

New 15-inch MacBook Pro

A few days ago, I bought a 15-inch MacBook Pro. For those of you keeping score, that brings the number of Macintoshes in our household to five. We also have two iPhones and several iPods. I wish the local Apple Store had some sort of customer loyalty program.

I bought this machine for work. (My wife will snicker at this statement, but it's true.) I've been toting a Toshiba tablet with Windows XP to the office for the past couple of years, but with each passing month, I've hated it more. Most of my development work has been for Linux, and I haven't needed Windows much. So, I've decided I'll finally ditch PC's for good.

I will have VMWare Fusion running Windows, Linux, and FreeDOS. For a contract programming gig a couple years ago, I ran Windows on my 13-inch MacBook with Parallels, and that worked pretty well, so I'm confident that a beefier Mac with VMWare can handle all my Windows needs from now on.

The new Pro is pretty. For the past few days, I've been preparing it for service by installing all the necessary software. On Monday, I'll take it to work, but I'll also take my old Toshiba for a few days until I'm sure the new machine can take its place.