Skip to content

Can't bridge NSData and UIImage to Blob according to Documentation in Swift3 #516

Closed
@Stanley-Tian

Description

@Stanley-Tian

The docs below seems outdated, any idea to make it work in swift 3 ?

extension NSData: Value {
    class var declaredDatatype: String {
        return Blob.declaredDatatype
    }
    class func fromDatatypeValue(blobValue: Blob) -> Self {
        return self(bytes: blobValue.bytes, length: blobValue.bytes.count)
    }
    var datatypeValue: Blob {
        return Blob(bytes: bytes, length: length)
    }
}

// assumes NSData conformance, above
extension UIImage: Value {
    public class var declaredDatatype: String {
        return Blob.declaredDatatype
    }
    public class func fromDatatypeValue(blobValue: Blob) -> UIImage {
        return UIImage(data: NSData.fromDatatypeValue(blobValue))!
    }
    public var datatypeValue: Blob {
        return UIImagePNGRepresentation(self)!.datatypeValue
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions