1

I use a simple macro in my code, I find it very convenient and useful

#define LogFunc NSLog(@"%p %s",self,__func__);

It gives me the self pointer address and the called function.

@implementation MyGreatClass

-(void)foo {
  LogFunc
}

-(void)bar {
  _supposeIamAnIVarBlock = ^(){
    LogFunc
  }

  _supposeIamAnIVarBlock();
}

@end

2016-03-01 16:35:01.990 MyApp[3447:2340168] 0x13102ecb0 -[MyGreatClass foo]

2016-03-01 16:35:01.990 MyApp[3447:2340168] 0x13102ecb0 -__27-[MyGreatClass bar]

Problem is, that when I use this Macro in blocks I might run into a retain cycle since self will be captured strongly. I know that I could use __weak or __block to avoid retain cycles, but that would blow my code up. I want LogFunc to remain very slim and quick to use... any Ideas?

Jakob
  • 1,126
  • 3
  • 16
  • 38

0 Answers0