ios - 如何在 Swift 2.3 中将 UInt8 转换为 Anyobject

标签 ios iphone swift swift2 type-conversion

我正在尝试使用 CryptoSwift 并尝试将 UInt8 转换为 Anyobject 。

如何转换

让加密:[UInt8]!

        encrypted = try AES(key: value, iv: iv, blockMode: .CBC, padding: PKCS7()).encrypt(myArray)

    let mynObject:AnyObject = encrypted as! AnyObject

无法将“Swift.Array>”类型的值 (0x11a6062e8) 转换为“Swift.AnyObject”(0x119d3d018)。

非常感谢任何人的帮助

谢谢

最佳答案

示例

let anInt:UInt8 = 20
let anObject:AnyObject = anInt as AnyObject

您要注意的关键部分是anInt as AnyObject,这是将 Uint8 转换为 AnyObject 的方法。

关于ios - 如何在 Swift 2.3 中将 UInt8 转换为 Anyobject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40105310/

相关文章:

ios - UISwitch 粘在 UITableViewCell 中

iphone - UIView 和 NSTimer 不释放内存

swift - Sprite Kit 和类型推断

iphone - 转换为 ARC 时,我们将 -dealloc 中的代码放在哪里?

ios - TextInput 崩溃 - 如何调试?

html - 固定导航栏与 iPhone 版 Chrome 浏览器顶部分开

ios - 子类上无继承导出

ios - 使用 iOS SDK 将同一设备上的多个用户登录到 ParseServer

ios - UIImageView 不会改变大小

iphone - 在 iphone 中显示/隐藏 TabBarController