Is this possible?
To make a concrete example, consider the following macro:
define pos
po ([self $arg0])
end
So now if I input pos text, it gets turned into po [self text]. But with multiple arguments, it fails, e.g. pos textLabel text gets turned into po [self textLabel] rather than the desired po [[self textLabel]text].
For another example, just as the three commands
po someIvar_
po [self someMethod]
po [[self someMethod]someOtherMethod]
print out the descriptions of the three objects referenced, it would be great to define a macro pi that does the same thing for integers, i.e.
pi [self someMethod]
is the same as calling
print (int)[self someMethod],
and similarly for
pi [[self someMethod]someOtherMethod].
user-defined commands are just a bit more than string-replaces before executing. Your example
pos textLabel textpasses two parameters to a command which only considers one parameter. The second is thrown away. It should result inpo [self textLabel]before executing. What you do is comparable to the following java-sum-function:int sum(int[] args){return args.get(0);}what you need is sth mentioned here :
I have not found any kind of a loop. So this should be the only way to do this except it is possible to to pop arg0 out of args and recursive-calls of user-defined-commands are allowed. But I think its easier to complete the example above.
pishould be implemented the same waymaybe there is a better solution but this brings you a step further towards your destination.