Possible Duplicate:
Can I pass a block as a @selector with Objective-C?
I have this code:
[myButton addTarget:self action:@selector(doSomething:) forControlEvents:UIControlEventTouchUpInside];
But since doSomething contains so little code, I was wondering if it is possible to put the code straight in here rather than making it run doSomething.
I have tried this already:
[myButton addTarget:self action:^ { /* code here */ } forControlEvents:UIControlEventTouchUpInside];
But it just gives an error of "sending (void)^(void) to incompatible type SEL".
Is there a way to do this? If so what is the correct syntax?
Thanks!