In Objective-C is there a way to get a list of the methods called by a method? -


i have been doing research online , have found using objectivec package in objective c can list of methods on class using class_copymethodlist(), , see can implementation (imp) of method using instancemethodforselector:. apple documentation here has been helpful far i'm stuck , not sure i'm looking find.

i want list of methods/functions called in given method's implementation can build call tree.

any suggestions? in advance!

this solution kind of hard way, , cause line of code in every method can make use of sqlite , save tracked methods..

methodtracker.h

@interface methodtracker : nsobject  @property (nonatomic) nsmutablearray *methodtrackarr;  + (methodtracker *)sharedvariables;  @end 

methodtracker.m

@implementation methodtracker  static id _instance = nil;  + (methodtracker *)sharedvariables {     if (!_instance)         _instance = [[super  allocwithzone:nil] init];      return _instance; }  // optional - (void)addmethod:(nsstring *)stringedmethod {     // or maybe filter by: -containobject avoid reoccurance     [self.methodtrackarr addobject:stringedmethod];     nslog("current called methods: %@", methodtrackarr); }  @end 

and using like:

otherclass.m

- (void)voiddidload {     [super viewdidload];     [[methodtracker sharedvariables] addmethod:[nsstring stringwithutf8string:__function__]];     // or directly     [[methodtracker sharedvariables].methodtrackarr addobject:[nsstring stringwithutf8string:__function__]]; } - (void)someothermethod {     // , need add in every method have (-_-)..      [[methodtracker sharedvariables] addmethod:[nsstring stringwithutf8string:__function__]]; } 

i suggest import methodtracker.h inside [projectname]-prefix.pch file.

sorry, double answer, deleted other 1 , have no idea how did happen..

hope have helped or @ least gave idea.. happy coding, cheers!


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -