首页 > 代码库 > iOS: 定义 Block

iOS: 定义 Block

 定义

typedef void (^RFAudioBasicBlock) (void);typedef void (^RFAudioSuccessBlock) (BOOL flag);typedef void (^RFAudioSuccessDetailBlock) (BOOL flag, NSURL *url, NSTimeInterval duration);typedef void(^RFAudioSuccessURLBlock) (BOOL flag, NSURL *url);

 作为参数

- (void)playWithURL:(NSURL *)url finishedBlock:(RFAudioSuccessDetailBlock)block;

 使用

[[RFAudioManager defaultManager] playWithURL:url finishedBlock:^(BOOL flag, NSURL *url) {    NSLog(@"播放结束:%@", url);}];