Marc Charbonneau’s Blog

Cocoa KVO tricks: binding to an array of arrays

May 13th, 2008 by Marc Charbonneau
Respond

Earlier this week I was working on a project where I wanted to filter a table view based on tags. The data model I was working with was very simple. My table view was bound to an array of objects through an NSArrayController, and each object had it’s own array of NSStrings which represented tags. My goal was to create a filter bar control, which I could bind to the array controller in order to popular the list of tags. The filter bar would display each unique tag once, and update itself when objects were added or removed, or an object’s tag array changed.

At first this seemed somewhat complicated. Implementing key value observing is easy, but I would have to observe both the array of objects and also each object’s individual tag array. Handling insertions, removals, and replacements adds to the complexity of the code I needed to write, all in order to solve what should be a simple problem. When I stopped to think about it, I went back to the documentation and found there was a much, much easier way of dealing with this situation:

[filterBar bind:@"tags"
toObject:arrayController
withKeyPath:@"arrangedObjects.@distinctUnionOfArrays.tags"
options:nil];

One last thing; in my case I actually had to use two array controllers, one for the filter bar, and another for the table view. Since I was using the filter bar to create an NSPredicate for the table view’s array controller, if I bound both UI objects to that same array controller I would be removing tags from the filter bar after I applied the predicate! To avoid this, just create two array controllers and bind them both to the same NSMutableArray (just setting the content outlet won’t work).

Tags:   · · No Comments.

Thoughts on ExpanDrive

April 24th, 2008 by Marc Charbonneau
Respond

I started using ExpanDrive today, a SFTP application that uses MacFUSE to access a remote server in Finder. There was a good review of it a few weeks ago at Daring Fireball, and I’ve been hearing good things from several other developers.

The appeal of ExpanDrive is that it “just works;” you don’t have to worry about disconnecting or reconnecting to the server if your network connection changes (working from a MacBook Pro, mine frequently does) or any of the other problems that Finder sometimes has with remote volumes. With the exception of one Finder crash, ExpanDrive has worked very well with me. In no particular order, here are some quick thoughts, both good and bad (I’m currently using version 1.1).

  • I wish ExpanDrive had the option to display “.” hidden files in Finder, like .htaccess. There’s probably a hack to enable this systemwide, but it would annoy me to see them everywhere; I want it enabled just on my webhost. It’s not hard to use Terminal.app to open hidden files, but it would be better if it was an option, like it is in Transmit.
  • ExpanDrive doesn’t let Finder dump lots of metadate files (.DS_Store and ._Filename.txt) on your remote volumes, from what I can tell. That’s good! I was afraid this wouldn’t be the case, and it actually kept me from trying ExpanDrive at first.
  • Finder reports my webhost remote server as an 8TB volume with 8TB free. I could be wrong, but I assume that’s just the maximum volume size, not the actual disk space. It would be great if I could configure this per server, so Finder would report the actual disk quota for my hosting company.
  • ExpanDrive is fast! I’m not just talking about moving bits across the Internet either; copying, moving and editing files is just quicker through Finder than a separate FTP application like Transmit.
  • Bug report. Adding a “,” in the volume name causes the MacFUSE connection to fail. ExpanDrive showed it as connected until I restarted the application.
  • Minor annoyance, but I don’t like the menu bar icon. It’s too three dimensional compared to other menu bar icons, and there’s really no reason for me to use it often. A preference pane would have been better suited, with the option of showing a menu bar icon for users who disconnect and reconnect to drives more frequently than I do.

I still love Transmit, and I’m going to keep using it for some tasks, but I’m probably going to end up buying an ExpanDrive license when the demo expires. The allure of using SFTP reliably through Finder is just too much to resist.

Tags:   · 1 Comment

Cabel Sasser at C4[1]

April 12th, 2008 by Marc Charbonneau
Respond

I know it’s old, but last week I finally got around to watching Cabel Sasser’s C4[1] presentation.

Earlier this year I gave a talk (my first public presentation ever, actually!) at Johnny Rentzsch’s intimate and engaging C4[1] conference in Chicago. Despite nervousness, it was really great fun. We had just recently finished Coda, and with one hour to fill and a lot of Coda-related things still swirling around my mind, I pretty much just started talking. What followed was a whole lot of hyper-warp thoughts about all things Panic.

The presentation is great; lots of insight into the visual design process at Panic, and some of the challenges of developing Coda.

One of the more interesting parts was at the very end of the audience questions, where Cabel talks about the differences between developing a “big” application (Coda) and working on several tiny ones. Apparently the small applications each had enough feature requests and bugs that they took nearly as many resources and time as creating a larger application, only the smaller price tag meant only a fraction of the profits.

Tags:   · · No Comments.

David Heinemeier Hansson on Git

April 3rd, 2008 by Marc Charbonneau
Respond

From David Heinemeier Hansson’s blog:

So given all that, I think the Git move is even more interesting. That camp is competing not only to convince people that a new paradigm is appropriate for many things, but also as that it, one-out-of-many, should be the one to embody it.

I think they’re going to get it. Killer apps makes or breaks any platform. With Github, I think the Git hub just scored one. Rails is going to be hosted there for the launch. Capistrano, Prototype, and Scriptaculous already moved there.

Besides lots of public projects moving to Git, I’ve noticed developers asking about it on message boards, wondering what the big deal with distributed source control is and how they can move their existing Subversion repositories. I started using Git last year, so I’m glad it’s gaining popularity. Based purely on rumors I’ve heard, Git’s big competitor Mecurial is slightly better, but lacks critical mass from the developer community (and the blog posts, tutorials and tips that come from it).

Tags:   No Comments.

Runner’s Log 1.1.1

March 29th, 2008 by Marc Charbonneau
Respond

I just released another update to Runner’s Log this weekend, version 1.1.1. This release includes several important bug fixes as well as a few other small improvements. If you’ve had problems with the previous 1.1.0 release, give this a try!

Download the new version here, or read more about Runner’s Log.

Tags:   No Comments.

Mac OS X virtualization for developers

March 21st, 2008 by Marc Charbonneau
Respond

Cocoa developer Craig Hockenberry wants you to file a bug report on the OS X license restrictions that prevent desktop virtualization:

How can you develop new products for Leopard when you need to have Tiger installed for supporting your legacy applications? How easy is it to test a new feature on Mac OS X 10.4.11 when you’re running 10.5? How quickly can you reproduce a bug on 10.4.10 if you’re running 10.4.11? Can you run Xcode versions 3.0 and 3.1 at the same time from /Developer?

We all know the way to get Apple’s attention regarding our issues is to submit bugs. So now is the time to vote for virtualization. If you agree with the following, please copy and paste this bug report and submit it so that it becomes a duplicate of Bug ID# 5812840.

I agree with everything Craig is saying, and I can’t wait to see OS X virtualization available. As a developer, the benefits to testing software without switching computers or rebooting to a different operating system are enormous. The only downside is that virtualization will never allow me to emulate PPC processors along with Intel. Until I decide to cut support for PPC entirely (it will probably be a few years before I even consider this), I’m going to have to keep my old PowerBook on a side table for additional testing.

Tags:   · · No Comments.

Runner’s Log 1.1.0 Released

March 17th, 2008 by Marc Charbonneau
Respond

Although it took a lot longer than I expected, I’m pleased to announce the release of Runner’s Log 1.1.0. This is the first major update to Runner’s Log, and includes a number of great new features and improvements. First and foremost is the ability to import Nike+ data from iPods, something users have been asking for a long time (and I’ve wanted myself)! Also included are assigning locations to workouts, visual improvements to the user interface, bug fixes and more.

You can download the update here, or view the change log here. 1.1.0 is a free update if you have a license; new users can purchase a license through PayPal for $19.95.

Tags:   No Comments.

Cocoa development links of interest

March 11th, 2008 by Marc Charbonneau
Respond

Paul Kim:

Recently, Quentin Carnicelli of Rogue Amoeba asked if there were NSResponder methods that you could hook your “OK” and “Cancel” buttons to to dismiss a modal panel (or sheet). As far as I knew there wasn’t but, gosh darnit, that would be a useful thing to have.

To clarify what I’m talking about here, when you run your own modal window or sheet with “OK” and “Cancel” buttons (or some equivalents), you end up hooking those up to methods that dismiss the window/sheet, stop the modal session and return some code (either one for confirmation or cancellation). Most of the time, you end up writing the exact same code. It’s glue code that shouldn’t have to be written.

Jeff Johnson:

With STABS, you could build the release version of your app with debugging symbols, make a copy of the executable MyApp.app/Contents/MacOS/MyApp to keep, strip the executable for shipping, and then use the unstripped executable for symbolizing crash reports by giving a space-separated list of stack trace addresses to the command-line tool atos. Unfortunately, atos cannot currently serve this purpose with DWARF. Unlike STABS, DWARF does not include the debugging symbols in the executable itself but merely includes references to the intermediate object files, which do contain debugging symbols. You can usually find these .o files in a sub-directory of the build/MyApp.build directory. If you delete the object files after building with dwarf, you won’t be able to step through your app’s code. (With stabs, the object files are refuse.) You also won’t be able to step through the code if you strip debugging symbols from your app, even if you keep the object files, because the references to the object files will be gone from the executable.

Mike Ash:

Ultimately I think the trend is bad. Code signing itself is a neutral technology, but it gives incredible power to the system vendor, and that power is just waiting to be exercised and abused. I believe that the iPhone is serving as a testbed to see how users and developers will react to an environment with ubiquitous code signing and control. If it goes well I think we can expect to see our desktop Macs gradually move in this direction as well. Judging by how badly Apple’s developer servers were flattened during the SDK release it seems like there’s no way it won’t go well.

Tags:   · No Comments.

iPhone SDK

March 7th, 2008 by Marc Charbonneau
Respond

The iPhone SDK has finally landed, bringing with it real Exchange support, WPA2 and other goodies. You can watch the announcement event here, or read highlights and commentary at Daring Fireball.

Although I don’t own an iPhone (yet), I did download the SDK and look forward to playing with it. My feelings about the price structure seem to be about the same as what most other developers are thinking. The $99 listing fee is no big deal. In my experience, even semi-popular freeware applications can earn back more than that through donations. The 30% Apple commission is high, but at the same time the iPhone is opening up an additional revenue source that will augment existing sales. It’s also a really neat, fun platform to develop for.

As a user, I am a little concerned about iPhone applications that are built off of their desktop alternatives. For example, if I buy a license for Delicious Library 2, will I have to pay an extra $20 for an iPhone version (assuming one is eventually released)? Will the iPhone version be free, but intentionally crippled so you need or want the full desktop version? It would be great if the iPhone version could be unlocked with a desktop serial number, but it seems like this won’t be possible. Maybe developers will be able to create coupons that will work in the iTunes store, but I haven’t heard anything about that.

I’m going to buy an iPhone eventually, I’m considering holding out until the next revision. It seems like it June would be a perfect time to release a second generation iPhone along with the new firmware update.

Tags:   · · No Comments.

OmniGraffle 5 released

March 7th, 2008 by Marc Charbonneau
Respond

Congratulations to Omni Group for the latest release of OmniGraffle earlier this week. I haven’t had a chance to use it much yet, but it seems like an impressive release in terms of features and improvements, as well as taking advantage of new Leopard only technologies.

Omni applications have always had great attention to detail, which is one of the reasons both developers and users love their software. For example, OmniGraffle 5 has two sets of toolbar icons; a normal one for the standard OS X appearance, and a greyscale set that’s automatically used when you choose the ‘Graphite’ appearance in System Preferences. Neat.

Tags:   · No Comments.