Ios Swift BigInt至[UInt8]

Ios Swift BigInt至[UInt8],ios,swift,integer,bigint,Ios,Swift,Integer,Bigint,我正在使用swift 4,并且正在使用BigInt的这个实现: 我注意到没有本机方法可以将BigInt或NSDecimalNumber转换为[UInt8],你们中有人知道这方面的一个很好的实现吗,因为我还没有找到 谢谢BigUInt有一个 /// Return a `Data` value that contains the base-256 representation of this integer, /// in network (big-endian) byte order. publi

我正在使用swift 4,并且正在使用BigInt的这个实现:

我注意到没有本机方法可以将BigInt或NSDecimalNumber转换为[UInt8],你们中有人知道这方面的一个很好的实现吗,因为我还没有找到


谢谢

BigUInt
有一个

/// Return a `Data` value that contains the base-256 representation of this integer,
/// in network (big-endian) byte order.
public func serialize() -> Data 
方法(请参阅),所以您可以做的是

let bi: BigInt = ...
let bytes = Array(BigUInt(bi).serialize())

BigUInt
具有

/// Return a `Data` value that contains the base-256 representation of this integer,
/// in network (big-endian) byte order.
public func serialize() -> Data 
方法(请参阅),所以您可以做的是

let bi: BigInt = ...
let bytes = Array(BigUInt(bi).serialize())