Thanks, Slava, that works. Do you have any idea why that works, but sets of the two arrays are always disjoint? The Set method works for SecCertificate but not SecKey.
Jon > On Oct 24, 2017, at 6:10 PM, Slava Pestov <spes...@apple.com> wrote: > > isEqual is defined on NSObject. You could also try using an array of > AnyHashable and calling == instead of isEqual. > > Slava > >> On Oct 24, 2017, at 3:09 PM, Jon Shier <j...@jonshier.com> wrote: >> >> Slava: >> How would this change affect this code from Alamofire, used to compare >> two SecKey instances for public key pinning: >> >> outerLoop: for serverPublicKey in ServerTrustPolicy.publicKeys(for: >> serverTrust) as [AnyObject] { >> for pinnedPublicKey in pinnedPublicKeys as [AnyObject] { >> if serverPublicKey.isEqual(pinnedPublicKey) { >> serverTrustIsValid = true >> break outerLoop >> } >> } >> } >> >> I’m not sure why, but the AnyObject casting makes this work correctly, even >> in Swift 4. I’ve tried to “modernize” it by using Sets (compare the pinned >> keys with the available keys Sets) but it doesn’t work (hash implementation >> for SecKey is weird?). I’m guessing that with the AnyObject case and >> isEqual, some underlying implementation is changed and equality works >> properly (or well enough for this use). I’m happy to get rid of this hack, >> but I’m not sure of any other method to accomplish our goals here. >> >> >> >> Jon Shier >> >>> On Oct 24, 2017, at 6:02 PM, Slava Pestov via swift-evolution >>> <swift-evolution@swift.org> wrote: >>> >>> Hi all, >>> >>> Dynamic dispatch of methods through AnyObject is a source of implementation >>> complexity, has many known bugs which we are not going to fix, and no >>> longer makes sense now in an id-as-Any world; AnyObject is not the ‘common >>> currency’ type for arbitrary Objective-C objects anymore. >>> >>> I would like to propose we deprecate it as follows: >>> >>> - Unconditional warning in Swift 4.1, with a fixit to add an ‘as’ cast to >>> cast the base value to the right type >>> - Error in Swift 5 in -swift-version 5 mode >>> >>> Thoughts? Does anyone actually rely on this feature, instead of just >>> stumbling on it by accident once in a while? >>> >>> Slava >>> _______________________________________________ >>> swift-evolution mailing list >>> swift-evolution@swift.org >>> https://lists.swift.org/mailman/listinfo/swift-evolution >> > _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution