ios - How to call SecItemCopyMatching in Xcode 7 beta 4? -


in previous versions of xcode 6 , 7 swift, syntax work:

    var secureitemvalue: unmanaged<anyobject>?      let statuscode: osstatus = secitemcopymatching(keychainitemquery, &secureitemvalue)     if statuscode == errsecsuccess     {         let opaquepointer = secureitemvalue?.toopaque()          let secureitemvaluedata = unmanaged<nsdata>.fromopaque(opaquepointer!).takeunretainedvalue()          // use secureitemvaluedata...     } 

however, secitemcopymatching declaration has changed in xcode 7 beta 4:

old: func secitemcopymatching(_ query: cfdictionary, _ result: unsafemutablepointer<anyobject?>) -> osstatus

new: func secitemcopymatching(_ query: cfdictionary!, _ result: unsafemutablepointer<unmanaged<anyobject>?>) -> osstatus

...and secureitemvalue type not match.

the mechanism confusing before extract result, , i'm hoping somehow easier new declaration, don't know how declare correct type secureitemvalue variable , extract result.

this works on xcode 7 beta 4

var datatyperef: anyobject?      let status: osstatus = withunsafemutablepointer(&datatyperef) { secitemcopymatching(keychainquery cfdictionaryref, unsafemutablepointer($0)) }      if status == noerr {         return datatyperef as? nsdata     }     else {         return nil     } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -