Code Monkey home page Code Monkey logo

Comments (3)

bang590 avatar bang590 commented on July 26, 2024

@lancy the problem is if we want to add method to an OC class dynamically, we should know the type of all params and return value, but the JS function didn't mention these types. I'm figuring out a way to pass types from JS to OC, would be updated soon.

from jspatch.

leafduo avatar leafduo commented on July 26, 2024

@bang590 Objective-J would be a probably solution.

from jspatch.

bang590 avatar bang590 commented on July 26, 2024

Solved in 653074f. We can add new method to OC class now.
Thank you for the excellent advice.
demo:

defineClass('JPViewController: UIViewController', {
  viewDidLoad: function() {
    self.super.viewDidLoad();
    var width = require('UIScreen').mainScreen().bounds().width
    var btn = require('UIButton').alloc().initWithFrame({x:0, y:100, width:width, height:50})
    btn.setTitle_forState('Push JPTableViewController', 0)
    btn.addTarget_action_forControlEvents(self, "handleBtn:", 1 << 6)
    btn.setBackgroundColor(require('UIColor').grayColor())
    self.view().addSubview(btn)
  },
  handleBtn: function(sender) {
    var tableViewCtrl = JPTableViewController.alloc().init() 
    self.navigationController().pushViewController_animated(tableViewCtrl, 1)
  }
})

from jspatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.