Skip to main content

transfer_ptr

Function transfer_ptr 

Source
pub unsafe fn transfer_ptr<T>(ptr: *mut c_void) -> Option<SharedPtr<T>>
Expand description

Create a SharedPtr by transferring ownership of an existing raw pointer.

Does not increase the reference count - ownership is transferred to SharedPtr.

C++ equivalent: NS::SharedPtr<_Class> TransferPtr(_Class* pObject)

ยงSafety

  • The pointer must be a valid Objective-C object.
  • The object must have a retain count >= 1.
  • The caller transfers ownership and must not release the object.