Skip to content

Commit df77599

Browse files
committed
Add a TODO hint for writing to a stream from JSONSerialization
1 parent 7d56b66 commit df77599

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Foundation/NSJSONSerialization.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ open class JSONSerialization : NSObject {
184184
open class func writeJSONObject(_ obj: Any, toStream stream: OutputStream, options opt: WritingOptions) throws -> Int {
185185
let jsonData = try _data(withJSONObject: obj, options: opt, stream: true)
186186
let count = jsonData.count
187-
return jsonData.withUnsafeBytes { (bytePtr) -> Int in
188-
return stream.write(bytePtr, maxLength: count)
187+
return jsonData.withUnsafeBytes { (bytePtr: UnsafePointer<UInt8>) -> Int in
188+
let res: Int = stream.write(bytePtr, maxLength: count)
189+
/// TODO: If the result here is negative the error should be obtained from the stream to propigate as a throw
190+
return res
189191
}
190192
}
191193

0 commit comments

Comments
 (0)