JSManagedValue

Superclass:
NSObject
Declared In:

Introduction

JSManagedValue represents a "conditionally retained" JSValue. "Conditionally retained" means that as long as either the JSManagedValue's JavaScript value is reachable through the JavaScript object graph or the JSManagedValue object is reachable through the external Objective-C object graph as reported to the JSVirtualMachine using addManagedReference:withOwner:, the corresponding JavaScript value will be retained. However, if neither of these conditions are true, the corresponding JSValue will be released and set to nil.

The primary use case for JSManagedValue is for safely referencing JSValues from the Objective-C heap. It is incorrect to store a JSValue into an Objective-C heap object, as this can very easily create a reference cycle, keeping the entire JSContext alive.



Methods

-initWithValue:

Create a JSManagedValue.

+managedValueWithValue:

Create a JSManagedValue from a JSValue.


initWithValue:


Create a JSManagedValue.

- (instancetype)initWithValue:(JSValue *)value; 
Parameters
value
Return Value

The new JSManagedValue.


managedValueWithValue:


Create a JSManagedValue from a JSValue.

+ (JSManagedValue *)managedValueWithValue:(JSValue *)value; 
Parameters
value
Return Value

The new JSManagedValue.


Properties

value

Get the JSValue from the JSManagedValue.


value


Get the JSValue from the JSManagedValue.

@property (readonly,
    strong) JSValue *value; 
Return Value

The corresponding JSValue for this JSManagedValue or nil if the JSValue has been collected.