Skip to content

Implement -[NSData writeToURL:options:error:] #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2015

Conversation

lowell
Copy link
Contributor

@lowell lowell commented Dec 7, 2015

Cleaned up resubmission of #57, powered by awesome feedback™

public func writeToURL(url: NSURL, options writeOptionsMask: NSDataWritingOptions) throws {
NSUnimplemented()
guard let path = url.path where url.filePathURL == true else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building on linux i get this failure

Foundation/NSData.swift:444:45: error: cannot convert value of type 'NSURL?' to expected argument type 'Bool'
        guard let path = url.path where url.filePathURL == true else {
                                        ~~~~^~~~~~~~~~~

which is really strange since i don't get that on mac

- `guard`'s `where` now uses correct property (`fileURL`)

- Fix `userInfo` type
@parkera
Copy link
Contributor

parkera commented Dec 8, 2015

This is almost ready, but there is one thing to resolve here. The as NSString cast fails on Linux without the ObjC bridging enabled:

Foundation/NSData.swift:445:57: error: cannot convert value of type 'String' to type 'NSString' in coercion
            let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL." as NSString, // NSLocalizedString() not yet available

we could add the explicit bridge cast here, but actually I think that NSError's userInfo should be [String : Any] instead of [String : AnyObject]. This is consistent with the changes we've been making elsewhere so we can return Swift.String instead of Foundation.NSString, since the lack of bridging otherwise makes it difficult to use by the caller.

@parkera parkera merged commit a27b95b into swiftlang:master Dec 8, 2015
@parkera
Copy link
Contributor

parkera commented Dec 8, 2015

I pushed some other fixes for NSError so that we could split that problem from this one.

atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
 Allow multiple Xcode toolchains in the registry
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Apr 29, 2021
…th-sync

Re-enable clangd checks with workaround
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants