一. 基本函数 根据 sel 得到 class 的实例方法 Method class_getInstanceMethod(Class cls, SEL name) 根据 sel 得到 class 的函数指针 IMP class_getMethodImplementation(Class cls, SEL name) 给 class 添加方法 class_addMethod(Class cls, SEL name, IMP imp, const char * types) 替换 class 的 s…
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public vo…
最近做项目,要用到js的加.减.乘.除的计算,发现js浮点数计算会有一些误差. 网上有很多文章都有js浮点数计算误差的解决方法,说能解决这个问题,But…….比如一个加法函数,如下: function accAdd(arg1,arg2){ var r1,r2,m; try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0} try{r2=arg2.toString().split(".")[1].length…
继上次整理,一些东西没有整理完.就写在这.可能比较乱比较杂,因为都是整理的一些东西,也没有到做成专题的程度. 1.String.repeat() 大家要实现重复一个字符串的重复怎么写呢,反正我的第一想法就是: function repeat(str,n){ var sum=''; for (var i = 0; i <n; i++) { sum+=str; }; return sum; } console.log(repeat('ab',3)); 其实优化就是把多于的变量消除,多了一个sum变量…
最近在回答StackOverflow的问题时,发现performSelector方法在Swift被去掉,Apple的注释是这个方法被去掉是因为不安全: NOTE The performSelector: method and related selector-invoking methods are not imported in Swift because they are inherently unsafe. 如果在Swift调用这个方法会编译出错: 'performSelector' is…