Are there some interface on operations in Core Fundation? not Cocoa

124 views Asked by At

I'm trying to work on carbon to cocoa. There are some carbon apis that about getting & setting value on clipboard. All of them are in C/C++ files.

I searched many answers in the internet and apple developer website, all of them had suggest me that NSPasteboard, I also wrapp cocoa api about it in .m file and invoke them in C/C++ file, it solve me much, but not all.

PutScrapFlavor, I failed to wrap it with cocoa. Any suggestions here?

On the other hands, I really want there are some core foundation api could be called in existing C/C++ files, anyone knows this? not NSPasteboard in cocoa.

Thanks in advance!

2

There are 2 answers

0
Avi On

The clipboard/pasteboard is a UI concept, and the only supported UI toolkit is Cocoa. Whether or not you wish to use NSPasteboard, you have little choice in the matter.

Sorry.

0
Mark Bernstein On

PutScrapFlavor has no exact equivalent, because there just weren’t enough distinct flavors in a four byte character code.

Instead, the new clipboard uses UTI strings in place of flavors. Where you used to have 'TEXT' you now have kPasteboardTypeString, and where you used to have a private native type like 'Sp%!', you now have @"com.example.product.yourNativeFlavor".

So you're going to need a complete rewrite of your scrap handling. The good news is that the Cocoa scrap API is not very large and maps neatly onto the old Carbon API; you shouldn't find this very difficult. And you can probably reuse all your private scrap flavors without too much trouble.

Finally -- if you're a fellow veteran of Carbon -- drag and drop interaction through the pasteboard is infinitely better than wrangling drag flavors.