Questions tagged [toll-free-bridging]
21 questions
0
votes
0 answers
Using CF_SWIFT_NAME to import a C struct getter and setter that bridges to Foundation from Core Foundation
I have a struct, House, that I want usable in both Objective-C and in Swift (additionally, I just wanted to test the bounds of what I could and couldn't import from C to Swift).
House is defined as follows:
typedef struct {
NSUInteger number;
…

F. S.
- 1
- 1
0
votes
1 answer
Why can't NSSpeechsynthesier's class method availableVoices be bridged to a Swift array of strings?
In Apple's Working with Cocoa Frameworks it reads as if the Foundation and Swift Foundation frameworks work together through bridging. However, I noticed that while attempting to use NSSpeechSynthesizer's class method availableVoices() it allows me…

Laurence Wingo
- 3,912
- 7
- 33
- 61
0
votes
2 answers
Does CFBridgingRelease restore ownership to preexisting references without direct assignment?
If I have the following code:
// objective C++ code .mm
id texture = ...;
void* ptr = (void*)CFBridgingRetain(texture);
share_ptr_with_native_code(ptr);
[texture do_stuff]; // is this valid?
// native code .cpp
void…

Mrb83
- 85
- 5
0
votes
1 answer
Why use toll-free bridging for collections with custom memory-management semantics?
In the book
Effective Objective-C 2.0: 52 Specific Ways to Improve Your iOS and OS X Program
there is an
Item 49: Use Toll-Free Bridging for Collections with Custom Memory-Management Semantics
This chapter mainly explains the importance of…

PinkiePie-Z
- 525
- 1
- 6
- 28
0
votes
2 answers
Why is Swift Dictionary not bridgeable?
Dictionary is a bridged type, why is it that I can switch from Swift dictionary to NSDictionary but not the other way around? (Compile Error: NSDictionary is not convertible to 'Dictionary')
According to Apple's doc:
All NSDictionary objects can be…

Boon
- 40,656
- 60
- 209
- 315
0
votes
1 answer
OS X and FSEvents: How do you release a callback pointer supplied to an FSEventStreamRef?
I'm using FSEvents to monitor a directory, and whenever the directory changes I call a block which I originally passed into the FSEventStreamContext of the FSEventStreamRef. How do I release the block when it is time to stop monitoring the…

Steveo
- 2,238
- 1
- 21
- 34