Skip to content

How does calling from JS to Obj-C work? #34

Closed
@jlongster

Description

@jlongster

I added a method to my TeapotController object:

- (void)touchHappened {
  RCT_EXPORT();
  NSLog(@"happened");
  CC3Vector pos = teapotNode_.position;
  [teapotNode_ setSizeX: 10];
  [teapotNode_ invalidateGlobalTransformMatrix];
}

Looking through the source, it looks like I can add RCT_EXPORT to export a method. I can then call it like this:

var controller = require('NativeModules').TeapotController;
controller.touchHappened();

If I just log something in touchHappened, this works. But when I try to access an instance variable like teapotNode_, nothing happens... but I don't see how this works anyway. How is it exporting a method from an instance? What I have multiple instances of TeapotController? I don't see how I could require individual instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions