Skip to content

Commit b337dab

Browse files
committed
add a few missing NSData methods for writing to files
These methods were initially missed during the first imports of NSData's interface
1 parent 0dfaaf8 commit b337dab

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Foundation/NSData.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,28 @@ extension NSData {
414414
}
415415
}
416416

417+
public func writeToFile(path: String, atomically useAuxiliaryFile: Bool) -> Bool {
418+
do {
419+
try writeToFile(path, options: useAuxiliaryFile ? .DataWritingAtomic : [])
420+
} catch {
421+
return false
422+
}
423+
return true
424+
}
425+
426+
public func writeToURL(url: NSURL, atomically: Bool) -> Bool {
427+
if url.fileURL {
428+
if let path = url.path {
429+
return writeToFile(path, atomically: atomically)
430+
}
431+
}
432+
return false
433+
}
434+
435+
public func writeToURL(url: NSURL, options writeOptionsMask: NSDataWritingOptions) throws {
436+
NSUnimplemented()
437+
}
438+
417439
internal func enumerateByteRangesUsingBlockRethrows(block: (UnsafePointer<Void>, NSRange, UnsafeMutablePointer<Bool>) throws -> Void) throws {
418440
var err : ErrorType? = nil
419441
self.enumerateByteRangesUsingBlock() { (buf, range, stop) -> Void in

0 commit comments

Comments
 (0)