Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftunsafeBitCast and pointersSingle-choice MCQ

You unsafeBitCast a class instance to an Int to grab its address bits, store that Int, let the object deallocate, then unsafeBitCast the Int back to the class type and call a method. From ARC's perspective, what is the core danger?

let i = unsafeBitCast(obj, to: Int.self) // obj deallocates here let revived = unsafeBitCast(i, to: MyClass.self) revived.doWork()