> On Jun 30, 2016, at 2:19 AM, Brent Royal-Gordon <[email protected]>
> wrote:
>
>> Note that, unlike with NSError, the provided errorUserInfo requires String
>> keys.
>
> Is there any way this could be tightened further to require Error.UserInfoKey
> keys (where Error.UserInfoKey is a Notification.Name-style wrapper)?
Maybe. We had originally tried doing this, but it caused a lot of frustration
because NSError’s userInfo historically allowed non-string keys, so technically
it should be typed as [NSObject : AnyObject]. However, that type signature
means that one is “.rawValue”’ing all of the keys over and over:
userInfo[NSErrorUserInfoKey.myKeyName.rawValue] = foo
That said, this proposal eliminates the need for using those keys (and, indeed,
NSError) most of the time, and maybe we can write off non-string keys entirely
in Swift.
- Doug
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution