您的位置:首页 > 移动开发 > IOS开发

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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: