Archive for the “Cocoa” Category

Last week I pushed out a major rewrite of FontLabel. This new version includes a category modeled after UIStringDrawing that enables you to draw text in custom fonts in your own drawRect: methods. It also includes accurate font metrics and uses more of the built-in UILabel properties. Contributions are welcome!

Comments 2 Comments »

DNS-SD Browser has finally been released on the iTunes AppStore.

DNS-SD Browser is the iPhone version of my popular desktop Bonjour Browser software. It enables you to view all of the Bonjour services on your local network as well as on wide-area Bonjour domains.

Comments Comments Off on DNS-SD Browser is on the AppStore

Recently I was contracted to write some software, and it’s just now been released. It’s called GrabUp. Basically, the whole purpose here is for zero-click sharing of screenshots. GrabUp is a daemon that sits in the background and waits for you to take a screenshot, then it instantly uploads it to the GrabUp servers and puts the URL on your clipboard. It has a nice status item to let you know when it’s done. If you have GrabUp running and you want to share an image, just take the screenshot and then paste the URL anywhere. So far, GrabUp has been seen in TUAW and we also got a rather nice blog post reviewing it.

Comments 3 Comments »

I just released a new version of SafariSource which supports Safari 3.0 last night. This morning I received a Czech localization from Jakub Formanek, so I just released SafariSource v1.7.1. with the new localization.

So if you’re using Safari 3.0, or if you’re Czech, go ahead and download SafariSource. If you’re using Safari 2.x, please let me know it still works as I can’t test that with 3.0 installed.

Comments Comments Off on SafariSource update

Update: This code was written pre-Leopard, and as such doesn’t run under ObjC 2. See JRSwizzle for an updated version that runs under Leopard and Snow Leopard.

Method Swizzling is one common technique of people writing hacks, such as Safari Plugins. Unfortunately, it’s always suffered from a flaw, wherein swizzling inherited methods affects all classes which inherit that method (including the base class), rather than the intended subclass. This problem is discussed on the CocoaDev Method Swizzling page.

As part of writing YubNubSearch, I decided to solve this problem.

First I looked into dynamic subclass generation + posing. Unfortunately, this has a big problem. In this technique, calling the original implementation would naturally be done through a [super foo] call. Unfortunately, when the compiler sees super, it hardcodes a reference to the superclass at which to start the search. This means you cannot write this code in, say, a category on NSObject, then pull up the IMP into a dynamically-generated subclass and have it work. So that throws out that idea.

The other idea I had, which I eventually went with, was to copy inherited methods into the subclass that you wish to swizzle, before swizzling. It turned out to be fairly easy, and still has the same semantics as the old, flawed technique for calling the original implementation.

You can download my implementation here.

Comments 6 Comments »

I just polished up my SIMBL plugin for release. It’s called YubNubSearch and it allows you to use YubNub as your default search engine in Safari.

You can get it here.

Comments 5 Comments »

(This post was adapted from an email I sent to Mike Solomon).

Objective-C has a method caching mechanism that optimizes for the case where a small number of methods are called repeatedly on one (or more) objects of a given class. This happens very often; for example, if you iterate over an array to gather the results of performing an operation on each element, you’re going to be calling the same method on a bunch of instances of the same class. And in fact the -[NSEnumerator nextObject] method itself will also be cached.

The fact that method caching exists is common knowledge. However, what isn’t generally known is how that caching is implemented, and what it means for you if you want to hack around on the internals of a class.

Read the rest of this entry »

Comments Comments Off on Objective-C caching and Method Swizzling

Earlier today Yahoo! finally released Yahoo! Messenger for OS X 3.0 beta 1, with an incredibly positive reaction from the general public. This is the app that I’ve spent the last 8 months working on, and I’m really proud to have finally released our first public beta. Even if you don’t use the old client, you should check it out. It’s a 100% rewrite in Cocoa, with a brand new spiffy UI, Growl support, avatar support, and more.

Comments 19 Comments »

With the availability of a universal SIMBL plugin I’ve now released a universal version of SafariSource. Download here.

Comments Comments Off on SafariSource universal

I just stumbled across something interesting today while poking around rcd (the daemon that farms out remote control events). If you send the NSDistributedNotificationCenter notification name @"com.apple.dashboard.dismiss" (no object or userInfo dictionary) then Dashboard hides itself. That’s pretty neat!

On a side note, it turns out there is no way to hack rcd to farm remote control events out to non-Apple programs. It has all the appleevents and such that it uses hardcoded in. I was really hoping they did something like implement a generic remote control AE that they sent to any app that cared, but no, if you’re not iTunes, DVDPlayer, iPhoto, QuickTime Player, or Keynote, you won’t see hide nor hair of the events.

Update: Turns out there’s a companion @"com.apple.dashboard.awake" notification as well that, you guessed it, brings Dashboard forward.

Comments Comments Off on Quick Tip: Dismissing Dashboard Programmatically