Skip to content

Instantly share code, notes, and snippets.

@itsdamslife
Created March 20, 2017 08:58
Show Gist options
  • Save itsdamslife/6d79679ec2b602379d9ee306dafe80ef to your computer and use it in GitHub Desktop.
Save itsdamslife/6d79679ec2b602379d9ee306dafe80ef to your computer and use it in GitHub Desktop.
A memory utility function in Swift to return the address of a reference variable.
public struct MemUtil {
public static func address(_ o: UnsafeRawPointer) -> String {
let address = unsafeBitCast(o, to: Int.self)
return String(format: "%p", address)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment