The answer depends on whether you want a class or instance and whether it is the sender or receiver of the message that interests you.
For the receiver class, you can use the -class method (declared in NSObject ), i.e.
-(void)configure { NSLog(@"This logs from which sub class this method was called"); NSLog(@"Class of this object is %@", [self class]); }
The recipient instance is, of course, just self . If the sender you are interested in, you cannot receive it automatically, but you can pass it as an argument. This way you will have something like
-(void)configure:(id)sender { NSLog(@"This logs from which sub class this method was called"); NSLog(@"Class of object that called this method is %@", [sender class]); }
Vic smith
source share