AutoreleasingUnsafeMutablePointer

struct AutoreleasingUnsafeMutablePointer<Pointee>

A mutable pointer-to-ObjC-pointer argument.

This type has implicit conversions to allow passing any of the following to a C or ObjC API:

  • nil, which gets passed as a null pointer,
  • an inout argument of the referenced type, which gets passed as a pointer to a writeback temporary with autoreleasing ownership semantics,
  • an UnsafeMutablePointer<Pointee>, which is passed as-is.

Passing pointers to mutable arrays of ObjC class pointers is not directly supported. Unlike UnsafeMutablePointer<Pointee>, AutoreleasingUnsafeMutablePointer<Pointee> must reference storage that does not own a reference count to the referenced value. UnsafeMutablePointer's operations, by contrast, assume that the referenced storage owns values loaded from or stored to it.

This type does not carry an owner pointer unlike the other C*Pointer types because it only needs to reference the results of inout conversions, which already have writeback-scoped lifetime.

Inheritance CVarArg, CustomDebugStringConvertible, Equatable View Protocol Hierarchy →
Import import Swift

Initializers

init(_:)

Explicit construction from an UnsafeMutablePointer.

This is inherently unsafe; UnsafeMutablePointer assumes the referenced memory has +1 strong ownership semantics, whereas AutoreleasingUnsafeMutablePointer implies +0 semantics.

Warning: Accessing pointee as a type that is unrelated to the underlying memory's bound type is undefined.

Declaration

init<U>(_ from: UnsafeMutablePointer<U>)
init?(_:)

Explicit construction from an UnsafeMutablePointer.

Returns nil if from is nil.

This is inherently unsafe; UnsafeMutablePointer assumes the referenced memory has +1 strong ownership semantics, whereas AutoreleasingUnsafeMutablePointer implies +0 semantics.

Warning: Accessing pointee as a type that is unrelated to the underlying memory's bound type is undefined.

Declaration

init?<U>(_ from: UnsafeMutablePointer<U>?)

Instance Variables

var debugDescription: String

A textual representation of self, suitable for debugging.

Declaration

var debugDescription: String { get }
var pointee: Pointee

Access the Pointee instance referenced by self.

Precondition: the pointee has been initialized with an instance of type Pointee.

Declaration

var pointee: Pointee { get set }

Subscripts

subscript(_: Int)

Access the ith element of the raw array pointed to by self.

Precondition: self != nil.

Declaration

subscript(i: Int) -> Pointee { get }