JSPatch心得

转载请注明来源缓存

1 CGSize,CGPoint,CGRect的使用,直接调用x,y,width,height四个属性,并且不用加().
例子
defineClass('PZPhotoView', {
zoomRectForScale_withCenter: function(scale, center) {
var zoomRect = {x:0,y:0,width:0,height:0};
zoomRect.width = self.frame().width/ scale;
zoomRect.height = self.frame().height/ scale;
zoomRect.x = center.x - (zoomRect.width / 2.0);
zoomRect.y = center.y - (zoomRect.height / 2.0);
return zoomRect;
},
});

2 类方法覆盖,目前看无效.
3 日志输出
console.log("xxxx");
4 使用模式
建议客户端在执行成功后,缓存一下Patch内容,这样启动时就能够先读取缓存中的内容\,理论上就能够覆盖除了启动函数外的全部函数.
5 对象,使用时必定注意检查是否是无效对象.
6 写代码时,尽可能减小变量,函数名中的下划线字样.
7 常量,能够写在一个公共的地方.
8 block,必定注意weakself的写法,不然block会出现各类各样的问题,千奇百怪.
var weakSelf = __weak(self);
9 数字,BOOL类型,不须要调用integerValue,boolValue之类的接口,自动转换了.
10 coredata部分函数读取目前是失败的,不肯定缘由.函数

相关文章
相关标签/搜索