Skip to content

Problem with promises #77

@rasc42

Description

@rasc42

I'm trying to use a code similar to issue #58 and I'm getting a

EXC_BAD_ACCESS(code=1, address=0x0)

XWVScripting class:

class Bridge : NSObject, XWVScripting {
    dynamic var ret: Int = 0   
    func getValue(_ promise: XWVScriptObject){
        print("getValue")
        ret = 2
        promise.callMethod("resolve", with: [ret], completionHandler: nil);
    } 

JavaScript:

function updateRet(msg) {
    ret = msg
}

function registerVars()
{ 
    ret = 0;
    
    if (ret==0) {
        Bridge.getValue().then(function(result) {
                               updateRet(result)
                               });
    }
}

I have also tried to do it like in issue #58:

func getValue(promiseObject promise: XWVScriptObject) {
    //
}

But then I had another error, this time in JavaScript runtime saying that Bridge.getValue() was undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions