Skip to content

Implement missing stringValue and descriptionWithLocale APIs #277

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 1 commit into from
Mar 21, 2016

Conversation

seabaylea
Copy link
Contributor

The NSNumber reference documents the following two APIs which appear not to be implemented (even as calls to NSUnimplemented):

var stringValue: String { get }
func descriptionWithLocale(_ locale: AnyObject?) -> String

Additionally stringValue() is described as a call to descriptionWithLocale(nil).

I've therefore implemented descriptionWithLocal(), and stringValue() as a call through to it.

@@ -452,6 +456,12 @@ public class NSNumber : NSValue {
public func compare(otherNumber: NSNumber) -> NSComparisonResult {
return ._fromCF(CFNumberCompare(_cfObject, otherNumber._cfObject, nil))
}

public func descriptionWithLocale(locale: AnyObject?) -> String {
guard let aLocale = locale else { return description }
Copy link
Contributor

Choose a reason for hiding this comment

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

from a subclassing perspective, iirc this is a bit inverted - descriptionWithLocale should be the funnel point and description should call descriptionWithLocale(nil) but that is a minor 'nit since this is pretty reasonable as it stands.

phausler added a commit that referenced this pull request Mar 21, 2016
Implement missing stringValue and descriptionWithLocale APIs
@phausler phausler merged commit d0d8255 into swiftlang:master Mar 21, 2016
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.

2 participants