iOS 我的block笔记
2014-07-29 12:10
274 查看
.h里面
#import <UIKit/UIKit.h>
typedef NSString *(^square)(int,float,NSString *);//注意此处
@interface BlockTestVC :
UIViewController
@end
.m里面
- (void)viewDidLoad
{
[super
viewDidLoad];
square square1 = ^(int a,float b,NSString *c){
NSString *test = [NSString
stringWithFormat:@"%d+%f=%@",a,b,c];
return test;
};
[self test:square1];
}
-(void)test:(square)squ {
NSString *testStr = squ(6,6.66,@"大顺");//回调,并获取返回值
NSLog(@"%@",testStr);
}
#import <UIKit/UIKit.h>
typedef NSString *(^square)(int,float,NSString *);//注意此处
@interface BlockTestVC :
UIViewController
@end
.m里面
- (void)viewDidLoad
{
[super
viewDidLoad];
square square1 = ^(int a,float b,NSString *c){
NSString *test = [NSString
stringWithFormat:@"%d+%f=%@",a,b,c];
return test;
};
[self test:square1];
}
-(void)test:(square)squ {
NSString *testStr = squ(6,6.66,@"大顺");//回调,并获取返回值
NSLog(@"%@",testStr);
}
相关文章推荐
- iOS学习笔记10(8)—深入浅出 Cocoa 多线程编程之 block 与 dispatch quene
- ios学习笔记之block在ios开发中的应用
- IOS学习笔记之十一:用Block来实现回调
- 黑马程序员- IOS学习笔记-OC ARC、BLOCK、protocol
- iOS复习笔记10:使用Block
- IOS学习笔记24—block
- OC笔记 - iOS适配、block内存泄露、电话短信邮件等小功能(2015.3.27)
- iOS学习笔记基础-oc08protocol、代理模式、block
- IOS Block 笔记
- iOS 笔记之 Block
- IOS 学习笔记--关于对Block的理解
- iOS Block 学习笔记
- IOS学习笔记46--Block探究(二)
- IOS学习笔记之九:block的应用
- ios笔记--class关键字,Category,protocol和block笔记
- (转自:ff20081528)IOS学习笔记之block在ios开发中的应用
- IOS学习笔记42--Block探究(一)
- ww笔记-iOS之用Block替代代理传回push之后的值
- ios学习笔记之block在ios开发中的应用
- iOS笔记---Block