上一篇主要功能是利用AFHTTPSessionManger 下载功能。在下载功能中利用到了
downloadVC.block = ^(DownloadMusic *model) {
// block 回调时 播放本地音频
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Download/%@.mp3", kCachesPath, model.name]];
self.model.playUrl64 = url.absoluteString;
// NSLog(@"+++++%@", self.model.playUrl64);
self.model.title = model.name;
self.model.coverLarge = model.imageUrl;
self.model.Duration = model.totalTime;
[[Mp3Player sharePlayer] musicPause];
[self updateUI];
};
这是利用到了 block 在downloadVC页面通过点击cell 传一个model过来
在downloadVC具体怎么使用block的
下面代码
typedef void(^MyDownMusicBlock)(DownloadMusic *model);
@property (nonatomic, copy) MyDownMusicBlock block;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DownloadMusic *model = self.modelArray[indexPath.row];
self.block(model);
[self.navigationController popViewControllerAnimated:YES];
}
这里的block是对musicplayerVC中对block回调的反应。