runtime为hook提供基础
2. ios runtime浅析(三):Method Swizzling
(1)典型的应用就是,修改系统方法的实现: category + runtime
举个例子,比如你想记录一个iOS应用里每个view controller显示的次数:可以在每个view controller添加记录的代码,但这会导致大量的重复代码;通过继承也是一个方法,但需要同时创建UIViewController, UITableViewController, UINavigationController及其它中view controller的子类,同样也会产生许多重复的代码出现。
(2)单独的category可以为系统类添加新的方法。