问题描述:

How do I do an objective C toll free bridge in Delphi?

e.g. I have a CFDictionaryRef and I want to use it as an NSDictionary, do I just do a wrap to covert it from a CF* instance to an NS* instance?

I can convert from an NS to a CF by

var

cfvariable CF*;

nsvariable: NS*;

begin

...

cfvariable := (nsvariable as ILocalObject).GetObjectID

But the other way seems to be causing me problems sometimes - i.e. sometimes it works sometimes it crashes. So wondering if I'm doing this the right way or the problem is somewhere else, e.g. for a CFDictionaryRef to an NSDictionary I do

var

attr : CFDictionaryRef;

nattr: NSDictionary;

begin

...

attr := CFDictionaryCreate(...);

nattr := TNSDictionary.Wrap(attr);

Is this the right way to do it?

(Delphi XE6 app on OSX)

Update: It does seem this is the right way to do it, the problem was elsewhere. I'll leave it up here in case any one else needs to know since its not documented well.

相关阅读:
Top