Objective C best way to see how many times a method is called

[亡魂溺海] 提交于 2019-12-24 08:28:06

问题


I want to determine how many times a particular method is called on NSManagedObject.

What are anybody's suggestions for the best way of doing this?

Bearing in mind that i have 30+ managed objects and I don't want to change the superclass of all of them.

Thanks


回答1:


-(void) method {

   static int callCount = 0;
   callCount++;

   /* method body */

}



回答2:


Create an alternate method in a category that tracks the number of calls in a static variable and the swizzle the method with the original implementation. See http://www.cocoadev.com/index.pl?MethodSwizzling for a code sample.



来源:https://stackoverflow.com/questions/7726353/objective-c-best-way-to-see-how-many-times-a-method-is-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!