Constructs a `WeakPtr` to the given object. Unsafe because the caller must ensure the given object pointer is valid.
(obj: *mut Object)
| 16 | /// Constructs a `WeakPtr` to the given object. |
| 17 | /// Unsafe because the caller must ensure the given object pointer is valid. |
| 18 | pub unsafe fn new(obj: *mut Object) -> Self { |
| 19 | let ptr = Box::new(UnsafeCell::new(ptr::null_mut())); |
| 20 | runtime::objc_initWeak(ptr.get(), obj); |
| 21 | WeakPtr(ptr) |
| 22 | } |
| 23 | |
| 24 | /// Loads the object self points to, returning a `StrongPtr`. |
| 25 | /// If the object has been deallocated, the returned pointer will be null. |