Skip to content

Commit

Permalink
Merge pull request #88 from LoganWright/no-nsdata
Browse files Browse the repository at this point in the history
remove nsdata conveniences
  • Loading branch information
loganwright authored Apr 18, 2017
2 parents c42a3f4 + 6fa0743 commit 8124baf
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions Sources/GenomeFoundation/Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,3 @@ extension Data: NodeConvertible {
self = data
}
}

// MARK: NSData

extension NSData: NodeRepresentable {
public func makeNode(context: Context = EmptyNode) throws -> Node {
var bytes = [UInt8](repeating: 0, count: length)
getBytes(&bytes, length: bytes.count)
let data = Data(bytes: bytes)
let js = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
return Node(any: js)
}
}


#if Xcode
/*
Linux won't compile this.
*/
extension NSData: NodeConvertible {}
extension NodeConvertible where Self: NSData {
public init(node: Node, in context: Context) throws {
let any = node.any
let data = try JSONSerialization.data(withJSONObject: any, options: .init(rawValue: 0))
self.init(data: data)
}
}
#endif

0 comments on commit 8124baf

Please sign in to comment.