Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completion handler is not called on iOS7 GM

I'm using AVAssetWriter, and it is perfectly working on iOS6.

The problem is, when I called finishWritingWithCompletionHandler, the completion handler is not called on iOS7 GM.

I called markAsFinished, and even endSessionAtSourceTime before I call finishWritingWithCompletionHandler.

It works fine on iOS6.

And even more, on iOS7, it works some times, and then it doesn't work again.

I don't know why, but it works if I call the method using alert view. So I tried performSelectorOnMainThread and inBackground, but it didn't help.

Any ideas?

like image 517
Seho Kim Avatar asked Sep 14 '13 12:09

Seho Kim


2 Answers

Apparently you need to retain the assetWriter now.

You might try retaining with a strong property it and see if your completion handler gets called. (Be sure to nil that property in completion handler.)

like image 90
Ray Fix Avatar answered Oct 19 '22 23:10

Ray Fix


Ray Fix, you are right. We need to retain assetWriter. The easiest way is to use it inside the finishWritingWithCompletionHandler block:

        NSError *error = nil;

        AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:path]
                                                                   fileType:AVFileType3GPP
                                                                      error:&error];
        //startWriting, session etc.  

        [videoWriter finishWritingWithCompletionHandler:^{
                NSLog(@"%@",videoWriter);
                NSLog(@"Write Ended");
            }];
like image 32
riskpp Avatar answered Oct 20 '22 00:10

riskpp