Skip to content

Instantly share code, notes, and snippets.

@SlaunchaMan
Last active May 26, 2017 16:24
Show Gist options
  • Save SlaunchaMan/30a2a3247a857edb3ce8b235785509a1 to your computer and use it in GitHub Desktop.
Save SlaunchaMan/30a2a3247a857edb3ce8b235785509a1 to your computer and use it in GitHub Desktop.
Hashing in a Mock Subclass of an NSObject
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