以下、READMEより転載。
What's In The Box
- Performing blocks on an NSObject.
- Key-value observation (
) with block handlers. - Associated objects in an Obj-C API. (Not directly block-related.)
- NSArray, NSSet, NSDictionary, and NSIndexSet filtering and enumeration.
- Macros for more quickly typing out the above.
- NSInvocation creation using a block.
- NSTimer block execution.
- Both delegation and block callbacks on NSURLConnection.
- Delegate callback for NSCache.
- UIAlertView, UIActionSheet with block callbacks and convenience methods.
- Block initializers for UIControl and UIBarButtonItem
- Block-backed initializers for UIGestureRecognizer.
- On-touch utilities for UIView.
- Block callbacks for MFMailComposeViewController and MFMessageComposeViewController.
- Delegate alternative for UIWebView.
リファレンスマニュアルが appledoc形式で提供されている。
BlocksKit Reference
以下、リファレンスから少し抜粋してみる。
UIActionSheet(BlocksKit)
UIActionSheet *testSheet = [UIActionSheet sheetWithTitle:@"Please select one."]; [testSheet addButtonWithTitle:@"Zip" handler:^{ NSLog(@"Zip!"); }]; [testSheet addButtonWithTitle:@"Zap" handler:^{ NSLog(@"Zap!"); }]; [testSheet addButtonWithTitle:@"Zop" handler:^{ NSLog(@"Zop!"); }]; [testSheet setDestructiveButtonWithTitle:@"No!" handler:^{ NSLog(@"Fine!"); }]; [testSheet setCancelButtonWithTitle:nil handler:^{ NSLog(@"Never mind, then!"); }]; [testSheet showInView:self.view];
NSObject(BlocksKit)
[object performBlock:^(){ [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; } afterDelay:0.5f];
UIGestureRecognizer もある。
UIGestureRecognizer(BlocksKit)
UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) { NSLog(@"Single tap."); } delay:0.18]; [self addGestureRecognizer:singleTap];
- - - -
かなり便利なので、いったん使い始めたら以後このライブラリ無しではコーディングできなくなりそうで怖い。。
Responses
Leave a Response