解析json从服务器获取图像

时间:2017-04-14 10:11:11

标签: ios json image swift2 uint8t

我在后端使用cassandra作为数据库和Java。我正在使用[UInt8]来保存图像。这是将图像转换为数组的代码

null

但我没有找到任何方法来取回我的形象。我从后端获得这种类型的json

func getArrayOfBytesFromImage(imageData:NSData) -> [UInt8]
    {

        // the number of elements:
        let count = imageData.length / sizeof(UInt8)

        // create array of appropriate length:
        var bytes = [UInt8](count: count, repeatedValue: 0)

        // copy bytes into array
        imageData.getBytes(&bytes, length:count * sizeof(UInt8))

        return bytes
    }

但我无法将其转换为数组[UInt8]。请帮我解决这个问题。

0 个答案:

没有答案
相关问题