Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我被卡通转换钥匙查询结果使用Swift。 我的要求似乎在工作: let queryAttributes = NSDictionary(objects: [kSecClassGenericPassword, "MyService", "MyAccount", true], forKeys: [kSecClas 我被卡通转换钥匙串查询结果使用Swift。

我的要求似乎在工作:

let queryAttributes = NSDictionary(objects: [kSecclassGenericPassword,"MyService","MyAccount",true],forKeys: [kSecclass,kSecAttrService,kSecAttrAccount,kSecReturnData])dispatch_async(dispatch_get_global_queue( disPATCH_QUEUE_PRIORITY_DEFAulT,0),{    var dataTypeRef : Unmanaged<AnyObject>?    let status = SecItemcopyMatching(queryAttributes,&dataTypeRef);    let retrIEvedData : NSData = dataTypeRef!.takeRetainedValue() as NSData    *** ^^^^can't compile this line^^^^})

我的问题是,代码不会编译:

Bitcast requires both operands to be pointer or neither  %114 = bitcast %objc_object* %113 to %PSs9AnyObject_,!dbg !487Bitcast requires both operands to be pointer or neither  %115 = bitcast %PSs9AnyObject_ %114 to i8*,!dbg !487LLVM ERROR: broken function found,compilation aborted!

我不知道如何转换非托管的< AnyObject>到NSData。

有任何想法吗?

使用withUnsafeMutablePointer函数和UnsafeMutablePointer结构来检索数据,如下所示:
var result: AnyObject?var status = withUnsafeMutablePointer(&result) { SecItemcopyMatching(queryAttributes,UnsafeMutablePointer([+++])) }if status == errSecSuccess {    if let data = result as NSData? {        if let string = Nsstring(data: data,enCoding: NSUTF8StringEnCoding) {            // ...        }    }}

它发布(Fastest [-O])构建工作正常。

总结

以上是内存溢出为你收集整理的使用Swift查询iOS钥匙串全部内容,希望文章能够帮你解决使用Swift查询iOS钥匙串所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
使用Swift查询iOS钥匙串_app_内存溢出

使用Swift查询iOS钥匙串

使用Swift查询iOS钥匙串,第1张

概述我被卡通转换钥匙查询结果使用Swift。 我的要求似乎在工作: let queryAttributes = NSDictionary(objects: [kSecClassGenericPassword, "MyService", "MyAccount", true], forKeys: [kSecClas 我被卡通转换钥匙串查询结果使用Swift。

我的要求似乎在工作:

let queryAttributes = NSDictionary(objects: [kSecclassGenericPassword,"MyService","MyAccount",true],forKeys: [kSecclass,kSecAttrService,kSecAttrAccount,kSecReturnData])dispatch_async(dispatch_get_global_queue( disPATCH_QUEUE_PRIORITY_DEFAulT,0),{    var dataTypeRef : Unmanaged<AnyObject>?    let status = SecItemcopyMatching(queryAttributes,&dataTypeRef);    let retrIEvedData : NSData = dataTypeRef!.takeRetainedValue() as NSData    *** ^^^^can't compile this line^^^^})

我的问题是,代码不会编译:

Bitcast requires both operands to be pointer or neither  %114 = bitcast %objc_object* %113 to %PSs9AnyObject_,!dbg !487Bitcast requires both operands to be pointer or neither  %115 = bitcast %PSs9AnyObject_ %114 to i8*,!dbg !487LLVM ERROR: broken function found,compilation aborted!

我不知道如何转换非托管的< AnyObject>到NSData。

有任何想法吗?

使用withUnsafeMutablePointer函数和UnsafeMutablePointer结构来检索数据,如下所示:
var result: AnyObject?var status = withUnsafeMutablePointer(&result) { SecItemcopyMatching(queryAttributes,UnsafeMutablePointer()) }if status == errSecSuccess {    if let data = result as NSData? {        if let string = Nsstring(data: data,enCoding: NSUTF8StringEnCoding) {            // ...        }    }}

它发布(Fastest [-O])构建工作正常。

总结

以上是内存溢出为你收集整理的使用Swift查询iOS钥匙串全部内容,希望文章能够帮你解决使用Swift查询iOS钥匙串所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1052572.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存