Making Foundation classes easier for Swift development

Hello Swift team and contributors!

I have been wondering about how existing Foundation classes, structs, and such types will be eventually adapted for use in Swift; I understand that, for example, the “NS”-prefix will be removed sometime in Swift 3. What I have been working with most recently has been NSFileManager and its `attributesOfItemAtPath` method which returns a type of [String: AnyObject]. Due to the nature of this, I’ve had to do some digging into the existing corelib-foundation source of NSFileManager to see how each item is assigned and which ones are guaranteed to be set and which ones I should be cautious of (e.g. could be nil).

So that said, are there any plans or thoughts on either changing current types, such as the return type of the aforementioned method, or adding new types to supplement things like this better? For the time being I have written my own small Swift module <https://github.com/RyanBreaker/SwiftFileAttributes&gt; for handling this easier, but I can’t help but feel edgy about it with all the explicit optional unwrapping.

Thanks,
Ryan Breaker
ryan@breaker.rocks <mailto:ryan@breaker.rocks>

Hi Ryan,

I don’t have anything concrete yet, but we are taking a very close look at the effect of dropping NS on items in the global namespace. I think it’s pretty clear we will need to do something to make the scope of those constants clearer once the prefix is gone.

- Tony

···

On Feb 1, 2016, at 11:00 AM, Ryan Breaker via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

Hello Swift team and contributors!

I have been wondering about how existing Foundation classes, structs, and such types will be eventually adapted for use in Swift; I understand that, for example, the “NS”-prefix will be removed sometime in Swift 3. What I have been working with most recently has been NSFileManager and its `attributesOfItemAtPath` method which returns a type of [String: AnyObject]. Due to the nature of this, I’ve had to do some digging into the existing corelib-foundation source of NSFileManager to see how each item is assigned and which ones are guaranteed to be set and which ones I should be cautious of (e.g. could be nil).

So that said, are there any plans or thoughts on either changing current types, such as the return type of the aforementioned method, or adding new types to supplement things like this better? For the time being I have written my own small Swift module <https://github.com/RyanBreaker/SwiftFileAttributes&gt; for handling this easier, but I can’t help but feel edgy about it with all the explicit optional unwrapping.

Thanks,
Ryan Breaker
ryan@breaker.rocks <mailto:ryan@breaker.rocks>
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev