The Quality Without A Name

2005/10/30

Tracing message sends in Objective-C

Filed under: Uncategorized — mayoff @ 10:05 pm

Update: It turns it there’s a much easier, more reliable way to see every Objective-C message send. So ignore the rest of this post and read about NSObjCMessageLoggingEnabled in TN2124.


So now I’m trying to get bindings working when I put my NSCell subclass in a table column. It appears, for the standard NSCell subclasses, that NSTableColumn looks at the subclass’s exposed bindings and re-exposes them on itself. However, it’s not doing that for my NSCell subclass’s bindings.

So, I want to trace the messages that are flying around inside Interface Builder to see if I can figure out how NSTableColumn decides what bindings to expose. Ideally I’d have a little dynamic library with a logging version of objc_msgSend and I could get Interface Builder to run using that. I don’t have that (yet). I found this old Usenet post from a NeXT engineer showing how to trace objc_msgSend using GDB. That will be much slower than smashing in a logging version of objc_msgSend, but it’s better than nothing.

Of course, the GDB command in that Usenet post is for NEXTSTEP running on Intel. It’ll probably work on MacOS X running on Intel, but my Powerbook has a PowerPC processor. Also, Apple introduced a new message-send function in Tiger, so you have to set two breakpoints. These commands work on MacOS X on PowerPC:

b objc_msgSend
comm
silent
printf "%c[%s %s]\n", $r3&&((id)$r3)->isa->info&2?'+':'-', $r3?((id)$r3)->isa->name:"nil", $r4
cont
end
b objc_msgSend_rtp
comm
silent
printf "%c[%s %s]\n", $r3&&((id)$r3)->isa->info&2?'+':'-', $r3?((id)$r3)->isa->name:"nil", $r4
cont
end

Here’s some sample output from GDB, tracing the first few messages sent in -[NSObject exposedBindings]:

-[NSTableColumn _bindingAdaptor]
+[NSBinder binderClassesForObject:]
+[NSBinder _allBinderClasses]
+[NSDisplayPatternTitleBinder isUsableWithObject:]
+[NSBox self]
-[NSTableColumn isKindOfClass:]
+[NSWindow self]
-[NSTableColumn isKindOfClass:]
+[NSWindowTemplate self]
-[NSTableColumn isKindOfClass:]
+[NSTableBinder isUsableWithObject:]
+[NSTableView self]
-[NSTableColumn isKindOfClass:]
+[NSObjectParameterBinder isUsableWithObject:]
+[NSObjectParameterBinder binderClassesSuperseded]
+[NSArray array]
+[NSArray allocWithZone:]

Dragging an NSCell subclass from an Interface Builder palette

Filed under: Uncategorized — mayoff @ 5:18 am

If you’ve got your own NSCell subclass that you want to put on an Interface Builder palette, you’ll probably think that you need to call -[IBPalette associateObject:ofType:withView:] using IBCellPboardType as the type. This doesn’t work. It turns out you need to use IBTableColumnPboardType. I don’t know what IBCellPboardType is for.

Also, IB will send -[NSCell setObjectValue:] to your cell to fill in the dummy values in puts it tables in design mode. So you have to be able to accept the values it sends (probably of type NSNumber and/or NSString), even if your cell doesn’t normally accept values of those types.

Also, if you want to see how IB’s built-in “Data Views” palette (the one with the table view and the cells on it) draws the built-in cells, open up this nib:

/Developer/Applications/Interface Builder.app/Contents/Resources/CocoaFramework.palette/Contents/Resources/IBDataViews.nib

It turns out to be kind of a hack, with two NSTextFields and some appropriate control (NSButton, NSSlider, etc.) on top of each other, nested in a simple NSView. The NSTextFields are set up to overlap, with the bottom one having a black border and the top one having no border and covering the sides of the bottom one.

It’s very handy to add a “custom executable” to your IB palette Xcode project, with the executable being “/Developer/Applications/Interface Builder.app”. Then you can press Command-R to start IB to test out your palette, or Command-Y to run IB under GDB so you can debug your palette. Be careful not to start IB by some other mechanism (like by double-clicking a nib) if you’re going to use this technique, because IB won’t start up correctly and (at least for me) Xcode will probably hang.

2005/10/14

Full screen QuickTime Player for free

Filed under: Uncategorized — mayoff @ 12:57 am

It’s fairly easy to make QuickTime Player go full screen, even if you don’t want to pay for “QuickTime Pro”. You can do it with a small AppleScript and the Script Menu. (This was inspired by QuikTimeFS, but that requires running an extra little application every time you want to go full screen.)

Instead of walking you through the process of enabling the Script Menu, creating the necessary folders, and using the Script Editor to create the one-line AppleScript, I’ve written an AppleScript that does all of those steps for you: Setup Full Screen.

After you download and run that, you’ll have the Script Menu toward the right end of your menu bar. It looks like this: Script Menu icon.

If you launch QuickTime Player, you’ll find a Full Screen script in the script menu:

Full Screen Menu Item

When you select that menu item, if you have a movie open, the movie will play full screen. You can press the Escape key (labelled “esc” at the upper left corner of your keyboard) to get back out of full screen mode.

If you don’t trust me, you can inspect the Setup Full Screen script by opening it with Applications > AppleScript > Script Editor.

Update: It turns out I’m not the only one to think of this. QT Full Screen does roughly the same thing, but uses an Installer package to install the full-screen script instead of doing it in an AppleScript.

2005/10/12

LabelWriter Catch-22

Filed under: Uncategorized — mayoff @ 9:05 pm

Meanwhile, I’m way, way behind in my filing. I wanted to catch up a bit, and discovered that my Dymo LabelWriter 330 Turbo (which prints my folder labels) is dead. If I want to get it fixed under warranty, I need to find the receipt. To find the receipt, I need to file my huge backlog of documents. To file my huge backlog of documents, I need to print folder labels.

Update: I found the e-mail receipt from buy.com (in my “Receipts” e-mail folder, no less). It’s still under warranty and I’ve got an RMA from Dymo.

More 2405FPW

Filed under: Uncategorized — mayoff @ 8:57 pm

I’ve been so spoiled by the Dell 2405FPW on my desk at work that I just ordered one for home (about $780 before tax thanks to a 35% deal that expires today). Now I have to decide whether to sell my 2001FP (20.1″ 1600×1200 LCD) or buy a PCMCIA video card so I can connect both to the Powerbook simultaneously.

Meanwhile, others at the company liked the 2405FPW enough that the company bought nine more of them.

Oh yeah, and the replacement for the defective 2001FP arrived Monday, right on schedule.

2005/10/06

video games

Filed under: Uncategorized — mayoff @ 11:07 pm

Ultimate Spider-Man: Disappointing. I was hoping for a game that would improve on the Spider-Man 2 experience. This didn’t. The graphics are fine – I like toon shading. The story is very short, and not nearly as good as Spider-Man 2‘s. The controls and the fighting are vastly simplified from Spider-Man 2. There is almost nothing in the way of ability upgrades, unlike Spider-Man 2.

We ♥ Katamari: Satisfying. There’s nothing revolutionary here, but there are some nice new features. Katamari Damacy left me wanting more, and this meets that desire well. The soundtrack is not as good, though.

Sly 3: Band of Thieves Satisfying. I thought the original Sly Cooper and the Thievius Racoonus was pretty good, and I thought Sly 2: Band of Thieves was great. This is a lot like Sly 2, but the clue bottles are gone, you get to play several extra characters with neat abilities, and the mini-games are quite fun. Also, remarkably, Sly’s special attacks work against the bosses, which is pretty unusual in my experience.

I’m looking forward to Shadow of the Colossus (from the creator of Ico), and I’ll probably buy SSX On Tour and Ratchet: Deadlocked too. Yes, I’ve noticed that five of these six games are sequels.

Dell support for the service-tag-impaired

Filed under: Uncategorized — mayoff @ 10:39 pm

If you have a Dell product with no service tag, and you need support, expect to spend a long time on the phone.

I bought a Dell 2001FP LCD monitor on 2005/2/17. A few days ago, it broke. Specifically, about 20 black lines now run down the center of the display, with a few pixels between each. These lines show up even in the self-test screen, so it’s definitely a problem in the monitor.

You can see the lines running across this image: Close Up of Broken Monitor They run horizontally in the image because I’ve got the monitor rotated 90°. The problem is much more apparent in real life. It’s difficult to photograph (at least with my crappy camera).

I quickly discovered that you cannot get on-line support unless you have a product with a service tag (a short unique string like a serial number). Dell monitors don’t have service tags. If you have the monitor connected to a Dell computer, you can use the computer’s service tag. My monitor is connected to my Apple PowerBook.

My only option was to call Dell tech support. The number wasn’t easy to find, either. I found it on the warranty page, which was also not as easy to find as it should have been:

http://www1.us.dell.com/content/topics/global.aspx/policy/en/policy?c=us&cs=19&l=en&s=dhs&~section=010

As you might expect, this was followed by a total of about 30 minutes on hold. They have promised to ship me a new monitor, and it should arrive Tuesday or Wednesday.

Blog at WordPress.com.