Last active
May 26, 2017 16:24
-
-
Save SlaunchaMan/30a2a3247a857edb3ce8b235785509a1 to your computer and use it in GitHub Desktop.
Hashing in a Mock Subclass of an NSObject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override var hashValue: Int { | |
var mutableSelf = self | |
return withUnsafePointer(to: &mutableSelf) { (ptr) -> Int in | |
return ptr.withMemoryRebound(to: Int.self, capacity: 1, { | |
return $0.pointee | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment