method

Objective-C 源码(四) 再次看 Method Swizzling

主宰稳场 提交于 2019-12-05 03:59:08
Method Swizzling 的原理 先打开 objc-private.h 文件 在 235行可以看到 Method的定义: typedef struct method_t *Method; 然后在 objc-runtime-new.h 文件中第82行可以看到: struct method_t { SEL name; const char *types; IMP imp; struct SortBySELAddress : public std::binary_function<const method_t&, const method_t&, bool> { bool operator() (const method_t& lhs, const method_t& rhs) { return lhs.name < rhs.name; } }; }; 从本质上讲:它就是struct method_t 类型的执行,包括了3个成员变量和一个成员函数: name:表示的是方法的名称,用于唯一标示该方法,比如@selector(viewWillAppear:); types:标示的是方法的返回值和参数类型; imp:是一个函数指针,指向方法的实现; SortBySELAddress 是一个根据name的地址对方法进行排序的函数。 由上面可以看出:Objective

网络编程-Tcp传输1

我的梦境 提交于 2019-12-04 20:33:30
一次简单的Tcp 传输import java.io.*; import java.net.*; public class Practice_1 { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub new Thread(new TcpClient()).start(); new Thread(new TcpSer()).start(); } } class TcpClient implements Runnable { public void run() { try { method(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void method() throws Exception { //1:创建Socket 、指定端口 Socket s = new Socket("199.234.8.53",10003); // 2:为了发送数据、应该获取socket中的输出流 。 OutputStream out = s.getOutputStream(); out.write("tcp ge men lai

Struts2理解--动态方法和method属性及通配符_默认Action

て烟熏妆下的殇ゞ 提交于 2019-12-04 09:12:15
众所周知,默认条件下,在浏览器输入indexAction!execute.action,便会执行indexAction类里的execute方法,这样虽然方便,但可能带来安全隐患,通过url可以执行Action中的任意方法。 想要禁止调用动态方法,则要在struts.xml中通过constant元素将属性strutsenableDynamicMethodInvocation设置为false,来禁止调用动态方法。 <constant name="strutsenableDynamicMethodInvocation" value="false"/> method属性: 这时我们需要通过其他安全的方式来实现动态方法的调用 一、通过action元素的method属性来指定Action执行时调用的方法 <action name="empAction_register" class="com.syaccp.erp.action.emp.EmpAction" method="register"> <result name="success">/WEB-INF/jsp/basic/emp_list.jsp</result> <result name="input_edit">/WEB-INF/jsp/basic/emp_edit.jsp</result> <result name="input

[转]C#中的abstract 类和方法

做~自己de王妃 提交于 2019-12-04 08:06:31
转: https://www.cnblogs.com/zzy2740/archive/2005/09/20/240808.html C#中的abstract类不能被实例化,他只提供其他类的继承的接口 using System; abstract class MyAbs { public void NonAbMethod() { Console.WriteLine("Non-Abstract Method"); } } class MyClass : MyAbs { } class MyClient { public static void Main() { //MyAbs mb = new MyAbs();//不能实例化 MyClass mc = new MyClass(); mc.NonAbMethod(); } } 一个抽象类可以包含abstract方法,也可包含实例化方法,但继承类(非抽象)必须实现abstract方法 abstract class MyAbs { public void NonAbMethod() { Console.WriteLine("Non-Abstract Method"); } public abstract void AbMethod(); // 抽象方法,只有声明,没有实现 } class MyClass : MyAbs//必须实现抽象方法 {

自定义express中间件

爱⌒轻易说出口 提交于 2019-12-04 01:23:11
const http = require('http') class LikeExpress { constructor() { this.middleList = [] this.routes = { all: [], get: [], post: [] } } // 处理参数 register(path) { const info = {} const slice = Array.prototype.slice if (typeof path === 'string') { info.path = path info.stack = slice.call(arguments, 1) } else { info.path = '/' info.stack = slice.call(arguments, 0) } return info } use() { const info = this.register.apply(this, arguments) this.routes.all.push(info) } get() { const info = this.register.apply(this, arguments) this.routes.get.push(info) } post() { const info = this.register.apply(this,

Android 弹出框的exception

99封情书 提交于 2019-12-03 15:52:39
java.lang.RuntimeException: Unable to start service com.zshfzb.pop.MyService@41a76f10 with Intent { cmp=com.zshfzb/.pop.MyService }: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@41a6c108 -- permission denied for this window type at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2515) at android.app.ActivityThread.access$1900(ActivityThread.java:133) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android

Mule ESB中entry-point-resolver的使用(4) Method Entry Point Resolver

回眸只為那壹抹淺笑 提交于 2019-12-03 10:25:40
Method entry point resolver是比较常用的entry point resolver。它根据用户提供的方法名以及Mule Message的Payload类型来匹配entry point。它的使用方式如下: ​<method-entry-point-resolver> <include-entry-point method="MethodEntryPointMethod1"/> <include-entry-point method="MethodEntryPointMethod2"/> </method-entry-point-resolver> ​ 这里指定了两个方法名,Mule ESB在匹配entry point时会先查找匹配第一个方法名的方法,如果没有找到,再查找匹配第二个方法名的方法,只要找到一个匹配的方法,会直接执行这个方法获得结果,而不会匹配其他匹配的方法。例如,我们在TestComponent类中定义了两个方法: public void MethodEntryPointMethod1(String message) { logger.info("MethodEntryPointMethod1's message is:" + message); } public void MethodEntryPointMethod2(String

Spring JdbcTemplate Insert throws uncategorized SQLException

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am inserting a new row into a table with Spring JDBCTemplate. The jdbcTemplate.update() throws the following exception: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [99999]; error code [17090]; operation not allowed But the row is inserted into the db anyway. Here's the code: final StringBuilder widgetInsert = new StringBuilder(); widgetInsert.append("INSERT INTO WIDGET (ID, KEY, DEPT_NUM, TYPE, CREATED_BY_ID, CREATED_DATE) "); widgetInsert.append("VALUES (WIDGET_SEQ.NEXTVAL, ?, ?, ?, ?, ?) "); Long widgetId;

What is causing “unbound method __init__() must be called with instance as first argument” from this Python code?

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this class: from threading import Thread import time class Timer(Thread): def __init__(self, interval, function, *args, **kwargs): Thread.__init__() self.interval = interval self.function = function self.args = args self.kwargs = kwargs self.start() def run(self): time.sleep(self.interval) return self.function(*self.args, **self.kwargs) and am calling it with this script: import timer def hello(): print \"hello, world t = timer.Timer(1.0, hello) t.run() and get this error and I can't figure out why: unbound method __init__() must be

Apache Client-cache jar

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I' trying to use Jira Rest Java Client's jar and have ran into a few bumps. I'm getting this error for a while now: java.lang.NoSuchMethodError: org.apache.http.impl.client.cache.CacheConfig.setNeverCache1_0ResponsesWithQueryString(Z)V at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClient.<init>(DefaultHttpClient.java:155) at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:53) at com.atlassian.jira.rest.client.internal.async