I just want to get a selector name, and the arguments, sender, or an NSInvocation instance every time when I send a message to an object. Possible? Something like forwardInvocation:, but in evey case (every method call).
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is way to get the selector’s name and the target by using the hidden parameters in objective-c messaging. From Apple’s documentation:
So in a method you can get the following:
If it’s still not enough for your needs, you can do the following:
Helper.id <HelperDelegate> myClassReference;[self method]instead create an instance of thisHelperclass and call the method on it like[helper method];and add this[helper setMyClassReference:self];.forwardInvocation:on theHelperclass. From there, you will be able to get theNSInvocationobject. Do what you need to do, and then:[anInvocation invokeWithTarget:myClassReference];so you can pass the message to the original caller.P.S: Even if this doesn’t answer your question, +1 for the question.. Really got me thinking about this.