Last active
March 12, 2019 11:35
-
-
Save Ksen17/f665b94cc8af3e6fa032cbfe2e21b128 to your computer and use it in GitHub Desktop.
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
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