首次竞争后运行任务

时间:2014-07-11 14:11:10

标签: ios objective-c objective-c-blocks

玩完后如何运行第三种方法? 在其他流中播放音频

我有一些方法

- (void)play {
    [self runTask:^{
        [self someMethod];
    } withCompletion:^{
        [self secondMethod];
    }]
;}


- (void)someMethod {
    NSLog(@"method 1");
    [[SoundManager sharedManager] playSound:@"" complete:^{
        [self thirdMethod];
    }];
}

- (void)secondMethod {
    NSLog(@"method 2");
}

- (void)thirdMethod {
    NSLog(@"method 3");
}


- (void)runTask:(void (^)())task withCompletion:(void (^)())completion {
    if (task) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            if (task) {
                task();
            }

            if (completion) {
                completion();
            }
        });
    }
}

也许你可以告诉我如何获得音频结束然后运行一些方法? 我使用AudioPlayerDelegate方法

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {

0 个答案:

没有答案