Code Monkey home page Code Monkey logo

Comments (9)

bang590 avatar bang590 commented on July 26, 2024

@cyvoit By now, JSPatch can't add method to an OC class if the method not exists in OC, I'm figuring out a way to solve this problem, would be update soon.

from jspatch.

erickyim avatar erickyim commented on July 26, 2024

I think tableView_didSelectRowAtIndexPath is an existing method - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPathof protocol UITableViewDelegate.

from jspatch.

bang590 avatar bang590 commented on July 26, 2024

@cyvoit it's a protocol, not an exists method.
[[[UITableViewController alloc] init] respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)] == NO

from jspatch.

wy19901227 avatar wy19901227 commented on July 26, 2024

but why the other method of protocol can be run?

from jspatch.

bang590 avatar bang590 commented on July 26, 2024

@wy19901227 because the base class UITableViewController implemented some of the methods.

from jspatch.

erickyim avatar erickyim commented on July 26, 2024
    XCTAssertFalse([[[UITableViewController alloc] init] respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]);
    XCTAssertTrue([[[UITableViewController alloc] init] respondsToSelector:@selector(tableView:cellForRowAtIndexPath:)]);

Test succeeded!
Maybe because cellForRowAtIndexPath is a required method while didSelectRowAtIndexPath is an optional method.

from jspatch.

wy19901227 avatar wy19901227 commented on July 26, 2024

how to test?

from jspatch.

erickyim avatar erickyim commented on July 26, 2024

@wy19901227 add the test code to a test file, e.g. JSPatchTests.m and run the test target. Maybe it's another topic.

from jspatch.

bang590 avatar bang590 commented on July 26, 2024

@cyvoit Solved in 653074f. We can add new method to OC class now.
The tableView_didSelectRowAtIndexPath is work now, but there is something wrong if the protocol method params type is not all id, will support protocol in the future.

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.