No Description

Data+bytes.swift 440B

123456789101112131415161718
  1. //
  2. // Data+bytes.swift
  3. // PaiAi
  4. //
  5. // Created by LISA on 2017/6/1.
  6. // Copyright © 2017年 yb. All rights reserved.
  7. //
  8. import UIKit
  9. extension Data {
  10. public func arrayOfBytes() -> [UInt8] {
  11. let count = self.count / MemoryLayout<UInt8>.size
  12. var bytesArray = [UInt8](repeating: 0, count: count)
  13. (self as NSData).getBytes(&bytesArray, length: count * MemoryLayout<UInt8>.size)
  14. return bytesArray
  15. }
  16. }