Archive for the ‘Mac’ Category

Hacking Mac OS X Tiger

Sunday, July 17th, 2005

If you’re the kind of person who likes to mess around under the hood of OS X (and I would wager most of the people reading this are), you might be interested to know that Mac legend Scott Knaster and those naughty folks at Wiley recently released a fun book called Hacking Mac OS X Tiger: Serious Hacks, Mods, and Customizations. Scott’s idea with this book was to recruit a whole bunch of Mac programmers to provide their favorite hacks, and put them together in one place with explanations of how they work. I personally contributed a hack I had written awhile ago to display iSight video on the desktop. If you’re looking for an interesting, offbeat programming book, check it out!

PodWorks 2.8.4 Released

Wednesday, June 29th, 2005

I have to confess, it’s been way too long since PodWorks saw an update. Well over a year, in fact. Part of this is due to my work on Cocoalicious, which consumes most of my non-work programming time; part of it is due to the fact that I consider PodWorks to be fairly mature and not really in need of a whole lot of bling-bling new features; and part of it is due to the fact that it’s been a long time since an iTunes update broke my database parser.

This streak ended with yesterday’s release of iTunes 4.9. The new iPod database format contains a new record type somehow related to podcasting, and it caused my parser to go off the rails. Fortunately, it was an easy fix, and I posted a new release this morning. If you use PodWorks, you’ll definitely want to download it.

The good news is that I didn’t need to do any additional work to add podcast support to PodWorks. The “Podcasts” list simply shows up as a playlist in the drawer, and the files within it can be accessed just like any other songs on the iPod.

Now, of course, I’m a bit curious what those new record types are for. Time to break out the old hex editor…

Name that Research Project…

Monday, June 27th, 2005

Andrew Pontious over at Helpful Tiger recently posted about a piece of software he’d like to see: an application that would scan emails (and possibly other text) and automatically pull out addresses and other contact information. This seems like a good idea to me–so good, in fact, that I could swear I remember hearing it before. Does anyone else recall there being some sort of Apple research project back in the (pre-Steve Jobs return) day that was doing something similar? Apple text filters, or something like that?

I swear it rings a bell, but maybe it’s just my own version of Roo Puffs

(Update: Daniel Wilson has it: Apple Data Detectors. There’s still an SDK for it and everything, evidently!)

How to Resize an NSImage

Saturday, June 25th, 2005

I decided to take a break from my normal rock and roll lifestyle (ha!) this evening to get some work done on Cocoalicious, with an eye toward doing a new release sometime next week. Specifically, I’ve been working on integrating and tweaking Eric Blair’s lovely favicon support patch.

In the course of polishing the favicon support, it occurred to me that we could improve performance a lot by pre-sizing the cached version of each favicon on download, instead of always resizing them on display (as it turns out, favicons in the wild come in all kinds of sizes). So I set to work changing the code to do just that, only to run up against a lot of confusion about just how to resize an image using NSImage.

At first glance it seems like the task is fairly straightforward. NSImage has a method called setSize, which the documentation says “sets the width and height of the image.” It seems like one should be able to simply read the data into the image, set its size, get the TIFF representation, and write that to disk.

Not so. As it turns out, setSize() only specifies how the image is displayed when it’s drawn–it does nothing to the underlying data. The most straightforward way to actually resize the data is to create another NSImage with the new size, lock focus on it, draw the source image into the new image, and then get the TIFF representation of the new, scaled image.

This may be obvious to some, but it certainly wasn’t to me, and I had trouble finding illuminating examples or explanations through Google, so I thought I’d post my code here to help anyone else who is similarly befuddled. If anyone has anything interesting to add on the subject, do let us know in the comments…

NSData *sourceData ... // Get your data from a file, URL, etc.
float resizeWidth = 13.0;
float resizeHeight = 13.0;

NSImage *sourceImage = [[NSImage alloc] initWithData: sourceData];
NSImage *resizedImage = [[NSImage alloc] initWithSize: NSMakeSize(resizeWidth, resizeHeight)];

NSSize originalSize = [sourceImage size];

[resizedImage lockFocus];
[sourceImage drawInRect: NSMakeRect(0, 0, resizeWidth, resizeHeight) fromRect: NSMakeRect(0, 0, originalSize.width, originalSize.height) operation: NSCompositeSourceOver fraction: 1.0];
[resizedImage unlockFocus];

NSData *resizedData = [resizedImage TIFFRepresentation];

[sourceImage release];
[resizedImage release];

WWDC 2005 Weblogger Dinner: Wrap Up

Sunday, June 19th, 2005



Three RSS Amigos

Originally uploaded by x180.

What can I say about WWDC this year? It was, in a word, intense!

Even though the weblogger dinner seemed to be attracting a lot of RSVPs, I don’t think I ever believed that 80 people were really going to show up until the last minute. I’m not sure exactly how many ended up attending, but as you can see from James Duncan Davidson’s great photos (thanks a million Duncan!), our space upstairs at The Thirsty Bear was pretty full at times.

Overall, I’m extremely happy with the way the event went, and I’m pleased that I was able to correct some of the mistakes I felt I made with last year’s dinner. Unlike our original space at Bucca di Beppo, the open room at The Thirsty Bear allowed everyone to circulate and talk to a variety of people, which I think made a huge difference. The food was also orders of magnitude better.

I think I’m most proud of the diversity of the crowd. Last year’s dinner was mostly Apple people and indie developers (read: people a lot like me), but this year I intentionally tried to bring some interesting outside influences in. I think it was really great to see the Mac dev crowd mix with the web crowd, large company developers mix with indie developers, and Apple employees mix with everyone else.

My personal highlights included putting together the above RSS aggregator developer group photo, watching Dan Wood and Terrence Talbot demo Sandvox to a very receptive audience, having a very long and enjoyable chat with a guy who turned out to be Marc Liyanage (when I found out who he was, I gushed about how I used to use his PHP and MySQL installers all the time), seeing Martin Pittenauer’s awesome Steve Jobs as Che Guevara shirt, talking so much that my voice just about gave out, watching Merlin Mann work the room, introducing lots of people, and generally seeing everyone have fun. My only real regret is that there were people who showed up that I didn’t get to talk to (and plenty of people I wanted to spend longer talking to than I did).

The other downside was the money, which, despite the fact that many people generously contributed far more than their fair share, still came up about $500 short. I hate dealing with the money part of the event, so normally I wouldn’t mention it, but since a number of people have asked, the DropCash campaign is still accepting contributions. Next year I think I may explore other ways of structuring the event to make the money part of it less of an issue.

All of that unpleasantness aside, though, I had a wonderful time, and I sincerely thank everyone for coming. I hope to see you all again next year!

I, for one, welcome our new little endian overlords

Saturday, June 11th, 2005



Cocoalicious on Intel

Originally uploaded by ldandersen.

As people who follow my Flickr photos have already seen, I spent some time at the WWDC Intel lab this week, creating universal binaries of PodWorks and Cocoalicious. Since people have expressed some curiosity about how it went, I thought I’d do a quick writeup on the subject.

Doing Cocoalicious was dead simple. It doesn’t rely on any embedded frameworks or other libraries that don’t ship with the system, and all of its networking code is handled by Web Foundation (which means endinanness is not something it really has to concern itself with), so getting it working was literally a matter of checking the little “Intel” box in Xcode.

PodWorks was a bit tricker. First of all, like NetNewsWire, it relies on several frameworks embedded within the app bundle, both of which need to be built as universal binaries before PodWorks itself can (this actually only caused build problems, most of which only happened because I was trying to get the projects set up on an unfamiliar machine with a new version of Xcode). Second, it statically links eSellerate’s serial number validation library, which is currently only distributed as a built PowerPC binary. This meant I had to strip out the serial number code before I could get it to build. Third, though I swore up and down to people that PodWorks uses NSSwapShortToHost to reverse the byte order of the iPod database’s little endian strings, I was in fact using NSSwapShort instead, meaning (rather embarrassingly ) that I was depending on the host processor being big endian.

As bad as all of that sounds, they’re still (mostly) fairly minor problems that I was able to resolve while sitting there in the lab with people looking over my shoulder, so I think my experience bodes well for 90% of the Mac developers out there. I’m with James Duncan Davidson and Brent Simmons in calling for Steve to bring the Intel based Macs on!

Congratulations Eric!

Saturday, June 11th, 2005

The first person I ever got to know at Apple was a really smart guy named Eric Albert. I read his weblog back when I was an Apple-obsessed Java developer in Colorado, eventually he started reading mine, and when I started interviewing for my current job, Eric helped me a lot by explaining how the Apple interview process works and what I should expect.

When I finally got to California, Eric and I would do lunch occasionally and talk shop. The only problem was, it tended to be a bit of a one-sided conversation. I would tell Eric about how the latest OS update was going and so on, and he would tell me…not much. Eric was unusually secretive about his work–even by Apple standards.

More recently, though, Eric started talking optimistically about his super secret project actually shipping. My co-workers and I thought we had a pretty good idea what he was working on (based on his background and the kinds of bugs he tended to file), but we all had a fun time coming up with wild, rumor site-grade theories about what it would actually be used for.

Then, last weekend, while I was hanging out in Los Angeles, I woke up to find CNet’s scoop on Apple’s Intel switch in my del.icio.us links, and I immediately knew that Eric’s long hours at work recently were about to pay off.

Yes, it’s true: Eric is one of those mysterious people Steve Jobs mentioned in the keynote–the people who have been secreted away making sure OS X works on Intel. Now that the truth can be revealed, I think Eric and the rest of his team deserve a hearty round of applause–both for doing a lot to improve the long term prospects of the Mac platform, and ensuring that what could have been a nasty transition will likely be almost transparent (he even spent a lot of time enthusiastically helping developers port their apps in the Intel lab at WWDC, as the screenshots I posted to Flickr attest).

Nice work Eric–enjoy your vacation!

Sandvox

Tuesday, June 7th, 2005

Before I post in detail about last night’s dinner (long story short: it kicked so much ass), I just wanted to take a moment to congratulate Dan Wood and Terrence Talbot on announcing their new app, Sandvox, yesterday at WWDC. Dan demoed it almost non-stop during the dinner last night, and I think everyone was pretty impressed.

Sandvox was intriguing to me because, while at first glance it appeared to be merely a very stylish WYSIWYG HTML editor, Dan’s demo quickly made it clear that a lot of its features (Blogger-style templates and automatic RSS generation, for example) are aimed squarely at the personal publishing/weblogging space (even its name hints at the goal of giving people a voice). I was also very impressed at the lengths Dan & company have gone to to hide the complexity of web publishing from the average user, ensuring that someone like my Mom would never have to deal with FTP (but without requiring her to sign up for a specific hosting service like .Mac). I won’t go into detail about it, but suffice to say their solution to the problem seems very clever.

Also, as everyone who was present last night probably heard me say at least five times, I do have a personal interest in Sandvox, since my little brother Bobby designed its lovely app icon. Now that his work with Dan has calmed down a bit (at least for now) Bobby has finally had time to put up his own weblog, and an interesting post discussing the evolution of Sandvox’s icon.

Cocoalicious 1.0b35: Star Ratings & More

Monday, May 30th, 2005

I’m back in Denver for Memorial Day, but the weather is so lousy that no one in my family has been able to build up the motivation to do much besides sit around my parents’ house. Fortunately, I’ve at least been able to use the downtime to get a lot of work done on Cocoalicious. The changes in 1.0b35 are mostly UI-focused, and include the following:

  • Star Ratings: Cocoalicious now recognizes tags that consist entirely of repeated asterix characters as star ratings, and displays the ratings in the post table as graphic stars, à la iTunes. The ratings can also be manipulated directly by dragging in the rating column (again, just like iTunes). See the screenshot I uploaded to Flickr if you’re wondering what this looks like.
  • Sortable Table Columns: This has to be the all-time winner for most inexcusable unimplemented feature in Cocoalicious. Fortunately, it’s finally in.
  • “Type-to-Select” in Tag Table: Typing while the tag table has focus will now cause the first match for the letters typed to be automatically selected (à la Address Book). This extremely useful and timesaving feature is courtesy of Ken Ferry’s excellent KFTypeSelectTableView class.
  • Delay of API HTTP requests: The del.icio.us API docs stipulate that clients should never submit more than one request to the API per second, and since the star rating feature makes that scenario a lot more likely, my del.icio.us API access code will now check to see if a second has elapsed since the last API request, and delay the request if it hasn’t.
  • Assorted bug fixes: Including one for a crasher that could happen on reload.

I’d also like to preemptively say that I realize not everyone will use the ratings, and that some people will want to be able to hide the ratings column. I ran out of time to implement that in this release, but will work on it for the next one.

Update: Damn–it looks like Jonathan Deutsch has found a crasher in b35 that eluded me. Stand by for a fix.

Say Hello to Ridiculous Fish

Thursday, May 26th, 2005

If I’ve ever introduced you to my colleague and friend Peter Ammon, you’ll probably remember me describing him as “one of the smartest people I’ve ever met.” Evidently I’m not alone in thinking that, because he was recently awarded what many of us Cocoa devotees would consider a dream job: an engineering gig on Apple’s AppKit team.

Before Peter left my group for the big time, a lot of us were trying to get him to start a weblog so that his frequent, witty insights about things like the horrors of object oriented Perl (he vociferously renounced Perl once after we sat through a presentation about its OO facilities), the perversity of C++, or what exactly happens in Objective-C when you message nil, wouldn’t be wasted on our daily lunch conversation.

Peter liked the idea, but true to overachieving form, kept us all eagerly waiting while he set about perfecting a fancy (and previously unknown, as far as I know) CSS box corner rounding technique as part of his site design. Fortunately, he now seems to be ready to go, and has launched his weblog at ridiculousfish.com. Mac developers who have been around long enough to have suffered through the incomplete early Cocoa documentation will undoubtedly smile at his first post.

Only time will tell how much Peter will feel he can write about his work, but I for one think having a weblogger on the AppKit team could be a great thing. Whatever he ends up writing about, I’m sure it will be worth reading, so I encourage everyone to give Peter a warm welcome to the blogosphere.