pointers - How to convert Unmanaged<CFTypeRef> to Swift 3 -


how override function swift 2.3 swift 3

 let unmanagedphones = abrecordcopyvalue(person, kabpersonphoneproperty)   let phones: abmultivalue = unmanaged.fromopaque(unmanagedphones.toopaque()).takeunretainedvalue() nsobject abmultivalue 

compiler says:'unmanaged<cftyperef>?' has no member 'toopaque'

please me

addressbook framework deprecated of ios9, , @ time apple say: "addressbook removed ios 10.x". better ready contacts framework soon.

you using redundant code parts not needed in swift2.

to retrieve t object unmanaged<t>?, need call takeretainedvalue() or takeunretainedvalue() immediately.

let phones: abmultivalue? = unmanagedphones?.takeretainedvalue() 
  • you should use takeretainedvalue() result of copy-ruled functions.
  • abmultivalue typealias of cftyperef in swift3, have no need cast result.
  • care nil-safe coding, unmanaged<t>? may nil.

Comments