I have a method that varies by a single method call inside, and I’d like to pass the method/signature of the method that it varies by as an argument… is this possible in Objective C or is that too much to hope for?
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.
NSInvocation is a class for wrapping up a method calls in an object. You can set a selector (method signature), set arguments by index. You can then set a target and call invoke to trigger the call, or leave the target unset and use invokeWithTarget: in a loop of some sort to call this on many objects.
I think it works a little like this:
Or if you dont want to pass invocation objects into this method you can use the SEL type to accept a selector (method signature).
Then assign the selector to an invocation object in order to call it on objects.