简体   繁体   中英

How to Convert UInt8 to Anyobject in Swift 2.3

I am trying in CryptoSwift and i tried to UInt8 to Anyobject .

How to Convert this

let encrypted:[UInt8]!

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

    let mynObject:AnyObject = encrypted as! AnyObject

Could not cast value of type 'Swift.Array>' (0x11a6062e8) to 'Swift.AnyObject' (0x119d3d018).

Anyone help really Appreciated

Thank you

Example

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

The key part you want to pay attention to is anInt as AnyObject this is how you convert a Uint8 to AnyObject.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM