Does anyone know how I can convert a `CFStringRefV...
# kotlin-native
a
Does anyone know how I can convert a
CFStringRefVar
to a Kotlin
String
?
a
Seems to be not an easy thing, I found a YT ticket on a similar problem(https://youtrack.jetbrains.com/issue/KT-38528) Maybe you can try to do something like that. Sketch based on the line from there:
Copy code
val refval:CFStringRefVar 
...
val string = CFBridgingRelease(refval) as String
a
I ended up converting it to a String in Swift and returning that instead. Maybe
CFBridgingRelease
is done automatically in Swift?
a
IIRC, the thing here is that NSString and CFStringRef are toll-free bridged in Objective-C and Swift. It means one don’t need to deal with those types differently manipulated in the ARC. To be fair, I’m not an expert in Apple’s system frameworks, but there is some subtle distinction between Cocoa and CoreFoundation classes. The thing I know for sure is that, for Kotlin, it’s getting much more complex. That should be made easier in time, that’s what (https://youtrack.jetbrains.com/issue/KT-29256) is about.
a
Ok thanks for the info! Now I know how this works in Kotlin Native right now.