S
S
Sahnen2020-09-07 13:34:27
Cocoa
Sahnen, 2020-09-07 13:34:27

How to initialize Unmanaged CFString?

Good afternoon.
I'm slowly learning Swift and got stuck on, it seems, little things, but I got stuck thoroughly.

Here is an example code:

import Foundation
import SystemConfiguration

var serviceID: Unmanaged<CFString> = .passRetained(NSString())
var userOptions: Unmanaged<CFDictionary> = .passRetained(NSDictionary())

let res = SCNetworkConnectionCopyUserPreferences(nil, &serviceID, &userOptions)
print("Res", res)
if res {
    print(serviceID.takeRetainedValue() as NSString)
    print(userOptions.takeRetainedValue() as NSDictionary)
}


No matter how hard I tried, res always comes with false. How does this bastard need to initialize the parameters in this case?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question