Skip to content

Recent Articles

14
May

CKImageAdditions

For several months I’ve been working on a set of categories on UIImage I call CKImageAdditions. They provide extra APIs to allow you to do more advanced image manipulation like blending one image over another, adjusting the hue or saturation and more. They also provide some convenience functions for CoreGraphics, like creating an bitmap context out of an image and a thread-safe replacement for UIGraphicsBeginImageContext().

Today, I pushed a bunch of fixes and made it fully compatible with iOS 3.x, and I’ve officially declared it 1.0. Check it out on GitHub.

28
Jul

Big Homestar Safari Extension

Whenever I went to developer.apple.com Apple seemed to be inviting me to join the Safari Developer Program.  It’s free, so why not.  But I figured if I’m going to be in the program I should at least write something.  So I wrote Big Homestar, a safari extension that makes everything on homestarrunner.com fill the browser window.  It even resizes as you resize the window.  This probably seems pretty trivial, but I don’t write much Javascript, so I’m pretty proud of it.

I submitted it to Apple for the gallery.  Then their server sent me an email saying that they reserve the right to do whatever and never talk to me again, or something like that.  But whether they like it or not, you can still get it here.

25
Jul

PCRE on the iPad

I’ve been working on an iPad application that relies heavily on preexisting regular expressions.   iPhone OS 3.2 doesn’t have much regular expression support, so naturally, I’ve been using RegexKitLite, a very easy to use Objective-C wrapper around the built-in ICU regex engine.  If you’ve never used it before I strongly recommend it.

Unfortunately, I found that I was having a lot of errors.   Turns out that ICU doesn’t support named capture groups, a feature many of these regular expressions required.   At first I thought, “Maybe I can go through them all and modify them so they didn’t need that feature,” but that would be far too tedious and inflexible for the future.  Then I thought, “Maybe I can add the feature to ICU, get it pushed into the release version then Apple will add it to the next update of the OS.”  Right.

I found that the best way to solve my problem would be to compile PCRE, the engine these expressions were originally written for (I think), for the iPad, which turned out to be very simple to do.  I also found ObjPCRE, an Objective-C wrapper that somebody had written a while back, but its interface seemed confusing and I never got it to work.  So I decided to figure out PCRE’s C API and write my own.  PCRE’s man pages are quite thorough and very helpful.  I only wish they had clear documentation of each function like Apple does.  Perhaps they’ve never heard of Doxygen.

Finally, I wrote PCRERegex, my Objective-C wrapper around PCRE.  It’s not very complete, I wrote it with a specific task in mind.  So don’t think you can just replace RegexKitLite with it just yet.  Maybe someday.  Maybe.

Go check it out on GitHub.