h1

Carbon/Cocoa differences

April 1, 2007

I’ve been using Macs for years and OS X since early Jaguar and I only noticed this yesterday. I don’t often go around changing file names of open documents in the Finder though.

There is definitely a difference in the way that Cocoa and Carbon applications deal with file names.

Cocoa Application

1. Create document in TextEdit and save it with a unique name.
2. Make some changes to the document.
3. With the document open, change the file name in the Finder
4. Make a further change in the document, save and close.

The original document retains the content from stage one and a new document is created in the same location, with the new file name and the amended content.

Carbon Application

1. Create document in Photoshop and save it with a unique name.
2. Make some changes to the document.
3. With the document open, change the file name in the Finder
4. Make a further change to the document and save

Before you close the window, notice the current open document has picked up the name change you made in the Finder.

This must be something in the relevant API, I reckon, I’m not programmer so I don’t know. I’ve passed this on to a couple of people and hopefully they’ll get back to me to either enlighten me or prove my ignorance.

UPDATE

I had to edit this because I goofed in my typing, though the point was understood. It should be that a new document with the new file name is saved in the same location for the Cocoa App. My appologies.

Advertisements

3 comments

  1. You’re right that it’s an API issue. Cocoa has traditionally identified files by their path and filename, whereas Carbon uses the more abstract idea of file references, called FSRefs. Cocoa even uses the Carbon functions internally for a couple of things (like if you rename a document while it’s closed, the Open Recent menu will still find it), but the Cocoa API is basically built around paths.

    I’ve been wanting them to fix this since 10.0. Hopefully Cocoa will get better FSRef-style file handling in Leopard.


  2. Thanks Chuck, I heard back from Cocoa Dev Center and they said the same. I didn’t know about Cocoa using Carbon functions in relation to Recent Items though, very informative.

    I don’t think we’ll see any great improvement in Leopard however.


  3. actually, while i am no GNUStep programmer or pro Cocoa programmer, i remember reading this in comments on an etoile programmer’s wikipage (http://www.etoile-project.org/)



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: