Contents

toDictionary()

Converts the JavaScript value to a dictionary.

Declaration

func toDictionary() -> [AnyHashable : Any]!

Return Value

The dictionary representation of the value.

Discussion

If the value is a JavaScript object, this method creates an NSDictionary object of the corresponding size, and recursively copies and converts all enumerable properties of the object into the dictionary with correspondingly named keys. JavaScript converts each element to a native object using the rules listed in Convert Between JavaScript and Native Types.

This method returns nil if the JavaScript value is null or undefined, and throws a JavaScript TypeError if the value is not a JavaScript object.

See Also

Reading and Converting JavaScript Values