views:

62

answers:

2

Hi All,

So We have a really old project that is all Carbon. We need to modify the way we open and save files and the dialog code we use is to old, so I wanted to create this new in Cocoa.

How does one create a Cocoa Class that can be called from Carbon?

What Cocoa routines would I use to create open and save dialogs and present them to the user, etc?

+1  A: 

I didn't think this was even possible and I was going to say as much, but Apple has published a Carbon-Cocoa Integration Guide [PDF] which might give you the answer you need.

However, I think you should consider porting the whole UI to Cocoa anyway. I don't know if Carbon is officially deprecated, but support of it is definitely not going to improve in future OS releases.

JeremyP
Specifically, Carbon UI is not available in 64 bit binaries.
JWWalker
@JWWalker: thanks. For some reason I had got it into my head that the UI was the bit of Carbon that *did* work in 64 bit, but I was wrong. http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/Carbon64BitGuide/Introduction/Introduction.html
JeremyP
+1  A: 

First you should consider whether your open and save dialogs should be sheets or modal dialogs. If they should be sheets, then you need to stick to the Carbon NavCreate... functions, because you can't have a Cocoa sheet on a Carbon window. If you are satisfied with modal dialogs, then probably you can use NSOpenPanel and NSSavePanel with the runModal method.

JWWalker