jspatch 使用心得:
判斷代碼替換是否成功,最簡(jiǎn)單的方法是在每一行都打上log輸出
console.log('開(kāi)始替換')
這樣就可以知道到哪一行執(zhí)行出現(xiàn)問(wèn)題,著重研究那一行代碼
1.require 把用到的類(lèi)名寫(xiě)下來(lái) require('UIColor');
2. oc中的get方法self.tableView 對(duì)應(yīng)是 self.tableView()
set方法self.tableView.backGroundColor 對(duì)應(yīng)self.tableView().setBackgroundColor(顏色)
3. oc中注冊(cè)cell時(shí)候需要用到類(lèi)名,比如[UITableViewCell class] 對(duì)應(yīng) UITableViewCell
4. 一般遇到枚舉值,直接用對(duì)應(yīng)的數(shù)字替換
5. 方法名,直接用雙引號(hào) 比如:@selector(doSomething) 對(duì)應(yīng) “doSomething”
6. 弱引用和強(qiáng)引用 var weakSelf = __weak(self); var strongSelf = __strong(weakSelf);
7. CGRectMake() 對(duì)應(yīng) {x:0, y:0, width:0, height:0}
8. 獲取私有變量利用lvc 比如: var cateTable = self.valueForKey("_cateTableView");
給私有變量賦值 self.setValue_forKey(“”,"_data")
9. dealloc方法不能替換。即使替換,原有的dealloc仍會(huì)繼續(xù)執(zhí)行
10.保持原有方法不變,只在后面添加?xùn)|西
defineClass("JPTableViewController", {
viewDidLoad:function() {
self.ORIGviewDidLoad();
},
})
其他遇到問(wèn)題后,最好是去官網(wǎng)文檔上尋找解決方案。這里只是自己的一些小總結(jié),留給自己以后看
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注