Evaluates a closure while ensuring that the given instance is not destroyed before the closure returns.
SDK
- Xcode 7.0+
Framework
- Swift Standard Library
Declaration
Parameters
x
An instance to preserve until the execution of
body
is completed.body
A closure to execute that depends on the lifetime of
x
being extended. Ifbody
has a return value, that value is also used as the return value for thewith
method.Extended Lifetime(_: _:)
Return Value
The return value, if any, of the body
closure parameter.