Created
January 23, 2011 04:12
-
-
Save rummelonp/791807 to your computer and use it in GitHub Desktop.
Objective-Cのクロージャ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make button block. | |
UIBarButtonItem* (^buttonWithTitle)(NSString*, SEL) = ^(NSString* title, SEL action) | |
{ | |
UIBarButtonItem* button = [UIBarButtonItem alloc]; | |
[button initWithTitle:title | |
style:UIBarButtonItemStyleBordered | |
target:self | |
action:action]; | |
[button setWidth:65.0f]; | |
[button autorelease]; | |
return button; | |
}; | |
// Make buttons. | |
UIBarButtonItem* some1Button = buttonWithTitle(@"some1", @selector(onClickSome1:)); | |
UIBarButtonItem* some2Button = buttonWithTitle(@"some2", @selector(onClickSome2:)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment