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
[SR-72] NSNumber is missing much parity #4475
Comments
Comment by David Owens (JIRA) After digging a bit more, I think this is OK. We can use the CFBoolean type and get by. |
Comment by David Owens (JIRA) Re-opening. I've found another wrinkle. let b: AnyObject = true This gets bridged to an NSNumber type. When you have the ObjC runtime, it gets the __NSCFBoolean type. So there is no way that I can see to get back from a Swift bool value for serialization/deserialization when AnyObject is in the interface. |
FWIW, the way the ObjC Foundation and CoreFoundation work is that creating an |
If (when?) we get proper factory method support from Swift, we should be able to return the private singleton subclasses directly. |
See also [SR-457] for a workaround but proper factory method support will make fixing this a lot cleaner |
Comment by Jens Alfke (JIRA) There needs to be a way to get the exact type of the stored number. The boolean case described above is just one example, but there are others:
In Apple Foundation the `objcType` property lets you do this (except with booleans, which return the wrong type code `c`). But that's obviously a bad name to use in a Swift API… |
Additional Detail from JIRA
md5: 67b10dfbfcf6c9bb009224f2a8b42473
is blocked by:
is duplicated by:
relates to:
Issue Description:
In the ObjC implementation of Foundation, NSNumber knows if it was created with a bool with the __NSCFBoolean type. However, this isn't true for the corelib version.
This functionality breaks our ability to implement serializers like NSJSONSerializer because all bools are treated as generic numbers now.
In addition to this, there is a lot of other functionality that is missing, such as comparison with kCFBooleanTrue values.
If this isn't currently being looked at internally, I can start fixing up these holes.
The text was updated successfully, but these errors were encountered: