Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's what I did:</p> <pre><code>typedef void(^EmptyBlockType)(); @interface YUYesNoListener : NSObject &lt;UIAlertViewDelegate&gt; @property (nonatomic, retain) EmptyBlockType yesBlock; @property (nonatomic, retain) EmptyBlockType noBlock; + (void) yesNoWithTitle:(NSString*)title message:(NSString*)message yesBlock:(EmptyBlockType)yesBlock noBlock:(EmptyBlockType)noBlock; @end @implementation YUYesNoListener @synthesize yesBlock = _yesBlock; @synthesize noBlock = _noBlock; - (id) initWithYesBlock:(EmptyBlockType)yesBlock noBlock:(EmptyBlockType)noBlock { self = [super init]; if (self) { self.yesBlock = [[yesBlock copy] autorelease]; self.noBlock = [[noBlock copy] autorelease]; } return self; } - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0 &amp;&amp; self.noBlock) self.noBlock(); else if (buttonIndex == 1 &amp;&amp; self.yesBlock) self.yesBlock(); [_yesBlock release]; [_noBlock release]; [alertView release]; [self release]; } - (void) alertViewCancel:(UIAlertView *)alertView { if (self.noBlock) self.noBlock(); [_yesBlock release]; [_noBlock release]; [alertView release]; [self release]; } + (void) yesNoWithTitle:(NSString*)title message:(NSString*)message yesBlock:(EmptyBlockType)yesBlock noBlock:(EmptyBlockType)noBlock { YUYesNoListener* yesNoListener = [[YUYesNoListener alloc] initWithYesBlock:yesBlock noBlock:noBlock]; [[[UIAlertView alloc] initWithTitle:title message:message delegate:yesNoListener cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil] show]; } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload