ios - Swift casting statement with CF -> NS classes -


while trying integrate address book framework , converting cf types ns classes swift classes, noticed strange:

abrecordcopycompositename(record)?.takeretainedvalue() as? nsstring

returns nil

abrecordcopycompositename(record)?.takeretainedvalue() nsstring?

returns optional("john smith")

my question isn't as? nsstring synonymous as nsstring? as? nsstring? (if so, why not?)

therefore, abrecordcopycompositename(record)?.takeretainedvalue() as? nsstring should equivalent abrecordcopycompositename(record)?.takeretainedvalue() nsstring? as? nsstring should return "john smith".

(this working on ios 8.3, ios 8.4 broke addressbook feature.)

as (ns)string? no supported syntax, might work in way.
either can cast forced (as!) or optional (as?) or can bridge (as) , there's no exclamation/question mark after type.

abaddressbookcopyarrayofallpeople() returns unmanaged<cfarray>! , abrecordcopycompositename() returns unmanaged<cfstring>!, both types unwrapped optionals, after calling takeretainedvalue() can bridge nsstring

abrecordcopycompositename(record).takeretainedvalue() nsstring 

or further string

abrecordcopycompositename(record).takeretainedvalue() nsstring string 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -