IOS Block使用

Block.h
#import <Foundation/Foundation.h>

typedef void(^SuccessBlock)(id result);


@interface Block : NSObject

+(void)passValue:(NSString *)str success:(SuccessBlock)success;

@end

Block.m

#import "Block.h"

@implementation Block

+(void)passValue:(NSString *)str success:(SuccessBlock)success
{
    success(str);
}

@end

// 使用
[Block passValue:@"test1111111111" success:^(id result){
        NSLog(@"result is %@",result);
    }];

 

posted @ 2014-03-04 17:19  菜鸟程序猿  阅读(206)  评论(0编辑  收藏  举报