BlockTest.h #import <Foundation/Foundation.h> typedef void (^didFinishBlock)(NSString *str); typedef void (^didFailBlock)(NSString *str); @interface BlockTest : NSObject +(void)justForTest:(NSString *)string finishBlock:(didFinishBlock)finishBlock failBlock:(didFailBlock)failBlock; @end BlockTest.m #import "BlockTest.h" @implementation BlockTest +(void)justForTest:(NSString *)string finishBlock:(didFinishBlock)finishBlock failBlock:(didFailBlock)failBlock { if ([string isEqualToString:@"test"]) { finishBlock(string); } else { failBlock(@"参数错误"); } } @end // 使用 [BlockTest justForTest:@"testt" finishBlock:^(NSString *str) { NSLog(@"%@",str); } failBlock:^(NSString *str) { NSLog(@"%@",str); }];