Skip to content

Instantly share code, notes, and snippets.

@Ksen17
Last active March 12, 2019 11:35
Show Gist options
  • Save Ksen17/f665b94cc8af3e6fa032cbfe2e21b128 to your computer and use it in GitHub Desktop.
Save Ksen17/f665b94cc8af3e6fa032cbfe2e21b128 to your computer and use it in GitHub Desktop.
import UIKit
class MyAwesomeClass: NSObject {
var a = "test"
}
var myClass = MyAwesomeClass()
var pointer = Unmanaged.passUnretained(myClass).toOpaque()
print(pointer) //0x0000600000020e20
print(myClass.a) //test
pointer.storeBytes(of: 23, toByteOffset: 0, as: UInt16.self)
let obj = pointer.load(as: UInt16.self)
print(pointer) // 0x0000600000020e20
print(obj) //23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment