English 中文(简体)
通过CFStringRef Pointer到MacRuby的C功能
原标题:Passing a CFStringRef pointer to a C function in MacRuby

我将以下职能称为DVDPlaybackOS X框架:

OSStatus DVDGetMediaVolumeCFName (
   CFStringRef *outDiscVolumeCFName
);

最后,我提出了以下工作守则:

framework  DVDPlayback 
p2 = Pointer.new_with_type( ^{__CFString} )
DVDGetMediaVolumeCFName(p2)

但我在任何文件中都找不到<代码>>> CFString}的比照,并且只发现了后来实际做些什么(我最初将它从错误信息中删除和贴出)。 我先审判点人,然后,两点:直截了当。

因此,我的问题是:

  • what s the best way to get this pointer (my way seems ugly)?
  • why didn t Pointer.new(:string) work? I thought String, NSString, and CFString were equivalent
  • where would I have looked to find this info? (I checked the MacRuby site, "macro Pointer" reported "Nothing known about Pointer", ~12 google hits, and "MacRuby: The Definitive Guide")
最佳回答

虽然存在一条从国家航天中心到CFStringRef的“免费”桥梁,但由于使用ARC(外交参考资料)而不适用于国家航天中心。 因此,要把CFStringRef* 引入国家统计系统,就必须使用_bridge

Pointer.new(:string)

不会奏效。 使用

Pointer.new_with_type( ^{__CFString} )

找到这一信息的最佳途径是观察在选择错误类型时产生的错误类型。 例如:

expected instance of Pointer of type `^{__CFString} , got `*  (TypeError)
问题回答

暂无回答




相关问题
Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签