Import |
|
---|
Static Methods
Unsafely turns an opaque C pointer into an unmanaged class reference.
This operation does not change reference counts.
let
str
:
CFString
=
Unmanaged.fromOpaque
(
ptr
).
takeUnretainedValue
()
value
: An opaque C pointer.
Returns: An unmanaged class reference to value
.
Declaration
static
func
fromOpaque
(
_
value
:
UnsafeRawPointer
) -
>
Unmanaged
<
Instance
>
Creates an unmanaged reference with an unbalanced retain.
The instance passed as value
will leak if nothing eventually balances
the retain.
This is useful when passing an object to an API which Swift does not know the ownership rules for, but you know that the API expects you to pass the object at +1.
value
: A class instance.
Returns: An unmanaged reference to the object passed as value
.
Declaration
static
func
passRetained
(
_
value
:
Instance
) -
>
Unmanaged
<
Instance
>
Creates an unmanaged reference without performing an unbalanced retain.
This is useful when passing a reference to an API which Swift does not know the ownership rules for, but you know that the API expects you to pass the object at +0.
CFArraySetValueAtIndex
(.
passUnretained
(
array
),
i
,
.
passUnretained
(
object
))
value
: A class instance.
Returns: An unmanaged reference to the object passed as value
.
Declaration
static
func
passUnretained
(
_
value
:
Instance
) -
>
Unmanaged
<
Instance
>
Instance Methods
Performs an unbalanced autorelease of the object.
Declaration
func
autorelease
() -
>
Unmanaged
<
Instance
>
Performs an unbalanced release of the object.
Declaration
func
release
()
Gets the value of this unmanaged reference as a managed reference and consumes an unbalanced retain of it.
This is useful when a function returns an unmanaged reference and you know that you're responsible for releasing the result.
Returns: The object referenced by this Unmanaged
instance.
Declaration
func
takeRetainedValue
() -
>
Instance
Gets the value of this unmanaged reference as a managed reference without consuming an unbalanced retain of it.
This is useful when a function returns an unmanaged reference and you know that you're not responsible for releasing the result.
Returns: The object referenced by this Unmanaged
instance.
Declaration
func
takeUnretainedValue
() -
>
Instance
Unsafely converts an unmanaged class reference to a pointer.
This operation does not change reference counts.
let
str0
:
CFString
=
"boxcar"
let
bits
=
Unmanaged.passUnretained
(
str0
)
let
ptr
=
bits
.
toOpaque
()
Returns: An opaque pointer to the value of this unmanaged reference.
Declaration
func
toOpaque
() -
>
UnsafeMutableRawPointer
A type for propagating an unmanaged object reference.
When you use this type, you become partially responsible for keeping the object alive.