Objective C 查看一个方法被调用多少次的最佳方式 [英] Objective C best way to see how many times a method is called
本文介绍了Objective C 查看一个方法被调用多少次的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想确定在 NSManagedObject 上调用特定方法的次数.
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?
请记住,我有 30 多个托管对象,我不想更改所有对象的超类.
Bearing in mind that i have 30+ managed objects and I don't want to change the superclass of all of them.
谢谢
推荐答案
在一个类别中创建一个替代方法,该方法跟踪静态变量中的调用次数,并将该方法与原始实现混合.请参阅 http://www.cocoadev.com/index.pl?MethodSwizzling 获取代码样品.
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.
这篇关于Objective C 查看一个方法被调用多少次的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文