How can I convert pointer to NSString to kotlin St...
# ios
a
How can I convert pointer to NSString to kotlin String? ObjC code:
Copy code
CFArrayRef interfaces = CNCopySupportedInterfaces();
    CFDictionaryRef networkInfo = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0));
    NSString *ssid = CFDictionaryGetValue(networkInfo, @"SSID");
I’ve wrote:
Copy code
val interfaces = CNCopySupportedInterfaces()
val interface: CFStringRef? = CFArrayGetValueAtIndex(interfaces, i)?.reinterpret()
val networkInfo = CNCopyCurrentNetworkInfo(interface)
val ssIdPtr = CFDictionaryGetValue(networkInfo, kCNNetworkInfoKeySSID)
val ssId = ?????
n
a
Thanks!
Copy code
val ssId = CFBridgingRelease(ssIdPtr) as String
n
an additional retain may be necessary, though