AutoreleasingUnsafeMutablePointer

struct AutoreleasingUnsafeMutablePointer

A mutable pointer addressing an Objective-C reference that doesn't own its target.

Pointee must be a class type or Optional<C> where C is a class.

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

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.

Initializers

init init(_:) Required

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

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

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

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

Subscripts

subscript subscript(i:) Required

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

Precondition: self != nil.

Declaration

@inlinable public subscript(i: Int) -> Pointee