another.im-ios/AnotherXMPP/utils/MemBridge.swift
2024-12-18 04:51:41 +01:00

12 lines
305 B
Swift

import Foundation
enum Mem {
static func bridge<T: AnyObject>(_ obj: T) -> UnsafeMutableRawPointer {
Unmanaged.passUnretained(obj).toOpaque()
}
static func bridge<T: AnyObject>(_ ptr: UnsafeMutableRawPointer) -> T {
Unmanaged<T>.fromOpaque(ptr).takeUnretainedValue()
}
}