-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add ListFormatter
#4794
base: main
Are you sure you want to change the base?
Add ListFormatter
#4794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little on the fence about this as there is new API surface that we need to create and expose from CF. @parkera what is your take? The changes to CF are pretty minimal and for a good reason - they are supporting API equality.
func test_locale() throws { | ||
XCTAssertEqual(formatter.locale, Locale.autoupdatingCurrent) | ||
|
||
formatter.locale = Locale(identifier: "en_US_POSIX") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not portable (en_US
is fine, en_US_POSIX
is not a valid locale on Windows).
} | ||
|
||
public required init?(coder: NSCoder) { | ||
self.cfFormatter = _CFListFormatterCreate(kCFAllocatorSystemDefault, CFLocaleCopyCurrent())! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the SCF does not support initWithCoder
. Shall we follow precedent and fatalError()
here?
|
||
open override func copy(with zone: NSZone? = nil) -> Any { | ||
let copied = ListFormatter() | ||
copied.locale = locale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we should just use the copy
method instead
Our plan of record here is to focus on https://github.com/apple/swift-foundation/, where we actually already have the |
This PR adds
ListFormatter
. Resolves #4223.https://developer.apple.com/documentation/foundation/listformatter