Skip to content

Commit a27b95b

Browse files
committed
Fixes to -[NSData writeToURL:options:]
- `guard`'s `where` now uses correct property (`fileURL`) - Fix `userInfo` type
1 parent 48f6012 commit a27b95b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Foundation/NSData.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ extension NSData {
441441
///
442442
/// This method is invoked in a `try` expression and the caller is responsible for handling any errors in the `catch` clauses of a `do` statement, as described in [Error Handling](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html#//apple_ref/doc/uid/TP40014097-CH42) in [The Swift Programming Language](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097) and [Error Handling](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/AdoptingCocoaDesignPatterns.html#//apple_ref/doc/uid/TP40014216-CH7-ID10) in [Using Swift with Cocoa and Objective-C](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html#//apple_ref/doc/uid/TP40014216).
443443
public func writeToURL(url: NSURL, options writeOptionsMask: NSDataWritingOptions) throws {
444-
guard let path = url.path where url.filePathURL == true else {
445-
let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL.", // NSLocalizedString() not yet available
446-
NSURLErrorKey : url.absoluteString ?? ""]
444+
guard let path = url.path where url.fileURL == true else {
445+
let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL." as NSString, // NSLocalizedString() not yet available
446+
NSURLErrorKey : url.absoluteString as NSString? ?? ""]
447447
throw NSError(domain: NSCocoaErrorDomain, code: 4, userInfo: userInfo)
448448
}
449449
try writeToFile(path, options: writeOptionsMask)

0 commit comments

Comments
 (0)