Invokes the given closure with a pointer to the given argument.
The withUnsafePointer(to:_:) function is useful for calling Objective-C
APIs that take in/out parameters (and default-constructible out
parameters) by pointer.
The pointer argument to body is valid only for the lifetime of the
closure. Do not escape it from the closure for later use.
Parameters:arg: An instance to temporarily use via pointer.
body: A closure that takes a pointer to arg as its sole argument. If
the closure has a return value, it is used as the return value of the
withUnsafePointer(to:_:) function. The pointer argument is valid
only for the duration of the closure's execution.
Returns: The return value of the body closure, if any.
Invokes the given closure with a pointer to the given argument.
The
withUnsafePointer(to:_:)
function is useful for calling Objective-C APIs that take in/out parameters (and default-constructible out parameters) by pointer.The pointer argument to
body
is valid only for the lifetime of the closure. Do not escape it from the closure for later use.Parameters: arg: An instance to temporarily use via pointer. body: A closure that takes a pointer to
arg
as its sole argument. If the closure has a return value, it is used as the return value of thewithUnsafePointer(to:_:)
function. The pointer argument is valid only for the duration of the closure's execution. Returns: The return value of thebody
closure, if any.See Also:
withUnsafeMutablePointer(to:_:)
Declaration
func
withUnsafePointer
<
T
,
Result
>
(
to
arg
:
inout
T
,
_
body
: (
UnsafePointer
<
T
>
)
throws
-
>
Result
)
rethrows
-
>
Result