iOS Block 写法详解
2016-03-29 10:49
423 查看
// // ViewController.m // test_block_1 // // Created by admin on 3/28/16. // Copyright © 2016 jeffasd. All rights reserved. // #import "ViewController.h" typedef void(^TestBlock)(int); typedef int(^TestAddBlock)(int, int); @interface ViewController () @property (nonatomic, copy)void (^addBlockResult)(BOOL) ; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"111"); _addBlockResult = ^(BOOL isSuccess){ NSLog(@" isSuccess is %@", [NSNumber numberWithBool:isSuccess]); }; _addBlockResult(YES); TestBlock testBlock = ^(int a){ NSLog(@"333"); NSLog(@"the test a is %d", a); }; NSLog(@"222"); testBlock(3); void (^ maxBlock)(int, int) = ^(int x, int y){ }; maxBlock(1, 2); int (^ minBlock)(int, int) = ^(int x, int y){ return x; }; minBlock(1, 2); [self testBlockResult:^(int x) { }]; [self testBlockResult1:^(int y) { }]; } - (void)testBlockResult:(TestBlock) testBlock{ } - (void)testBlockResult1:( void (^)(int )) myBlock { } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- iOS开发-多线程开发之线程安全篇
- iOS: ARC和非ARC下使用Block属性的问题
- bios导致的kvm_intel失败
- iOS开发-beginUpdates && endUpdates用法
- 又一个高性能轻量级的iOS模型框架YYModel
- iOS开发-获取WIFI信息
- ios 用户界面
- iOS协议传值封装总结
- IOS开发基础篇--NSNotificationCenter使用小结
- ios 属性中常用修饰词的总结
- iOS开发-"performSelector may cause a leak because its selector is unknown"警告原因及其解决办法
- ios设备运行出现 ”A valid provisioning profile for this executable was not found“的解决
- IOS中定时器NSTimer
- iOS开发 - 打开文件后进行文件分享(QLPreviewController)
- ios TableView性能优化技巧
- iOS 初始化单例
- iOS同一label设置不同颜色
- ios 星星评分(支持点击和滑动)
- iOS开发-系统级分享
- ios中json解析出现的null问题