Skip to content

Instantly share code, notes, and snippets.

@mlaster
Created September 22, 2018 23:05
Show Gist options
  • Save mlaster/9afe90715ade6154d2549d1299ce8338 to your computer and use it in GitHub Desktop.
Save mlaster/9afe90715ade6154d2549d1299ce8338 to your computer and use it in GitHub Desktop.
func createXPCDictionary(_ inDictionary: [String: Any?]) -> xpc_object_t {
var keyArray: [UnsafePointer<Int8>] = []
var valueArray: [xpc_object_t?] = []
for (key, value) in inDictionary {
keyArray.append(key)
let xo: xpc_object_t? = xpc_string_create(value as! String)
valueArray.append(xo)
}
precondition(keyArray.count == valueArray.count)
let keys: UnsafePointer<UnsafePointer<Int8>> = UnsafePointer(keyArray)
let values: UnsafePointer<xpc_object_t?> = UnsafePointer(valueArray)
print("keys: \(keys)")
print("values: \(values)")
print("count: \(keyArray.count)")
return xpc_dictionary_create(keys, values, keyArray.count)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment