ios - Prepend NSLog to all methods in Objective-C -


is possible configure class, such each method calls :

"nslog(@"%s", __pretty_function__);"  

prior executing?

for example, given:

@implementation myclass  - (void) methoda {     nslog(@"do in method a"); }  - (void) methodb {     nslog(@"do in method b"); }  @end 

the output [myclass methoda] :

"-[myclass methoda]"

"do in method a"

instead of:

"do in method a"

thank you.

there clever ways 1 this, assuming debugging class you've written , there many methods hand why not use find & replace?

note: opening brace @ end of line in code show following uses that, if change style you'll need change regular expression.

in xcode make sure pattern matching on: click magnifying glass left of search entry box, select edit find options..., set matching style regular expression

now in search field enter:

^-[^{]+\{ 

that matches: beginning of line (^), dash (-), not brace ([^{]) 1 or more times (+), , brace (\{).

do few searches make sure matching think. in replace field type:

\0 nslog(@"%s", __pretty_function__); 

which replaces matched (\0) followed nslog call.

reversing process can done similarly, left exercise.

hth


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -