[swift-evolution] Swift's Optional Int as NSNumber in Objective-C

Kenny Leung kenny at mail.hexdreams.com
Fri May 19 11:40:09 CDT 2017


Once again, the counter-argument is the the same. Before there was Swift, this is exactly what we would do, and it was never a surprise.

I would say the semantics of wrapped API should be taken from the viewpoint of the target language (ObjC), and not from the viewpoint of Swift.

-Kenny


> On May 16, 2017, at 3:04 PM, David Waite via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On May 15, 2017, at 8:24 AM, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> The argument is not about whether or not it should come through as an object. The argument is about the fact that *sometimes* it would come through as an object and other times it would not. Optionality isn't an obvious way to make that decision.
>> 
> 
> A second argument is that NSNumber does not represent an integer - only that it can be *initialized* by an integer. So the semantics of Int? -> NSNumber as an outbound result are completely different than the semantics of NSNumber -> Int? as an inbound parameter.
> 
> -DW
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list