问题
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