Why can't I set a Swift word element affected by JavaScriptCore?

I have a Swift object that I exposed JavaScriptCore as follows:

@objc(MyObjectExport) protocol MyObjectExport:JSExport { var name:String {get set} var dict:[String:String] {get set} } class MyObject:NSObject,MyObjectExport { var name:String="Name" var dict:[String:String]=["test":"TEST"] } 

In the context of Javascript, I can happily get and set the "name" property of an instance of MyObject, but only the dict dictionary can be entered for it.

What am I missing or is this a mistake?

+6
source share
1 answer

ECMAScript 5 does not support custom scripts. By providing a JavaScriptCore dictionary, you can do something in a JavaScriptCore, like

 MyObjectExport['key'] = value; 

But at this point it will not work in JavaScriptCore.

0
source

Source: https://habr.com/ru/post/989745/


All Articles