[ad_1]
Mainly, I need to print every time a category object is instantiated. The next code reveals the intent.
@interface NSObject (ILogger)
+ (void)initialize;
@finish
@implementation NSObject (ILogger)
+ (void)initialize
{
NSLog(@"Initializing %s", class_getName([self class]));
}
@finish
This doesn’t work as a result of NSObject already has a +initialize methodology so this method ends in undefined habits. The compiler additionally warns in regards to the problem: warning: class is implementing a technique which will even be applied by its main class
One thought can be to by some means swizzle +[NSObject initialize] and do the logging. How do I do this safely?
[ad_2]
