AVPlayer was deallocated while key value observers were still registered with it

前端 未结 5 1396
滥情空心
滥情空心 2021-01-31 08:45

I am creating a simple media player app. My App is crashed when first link is played and I clicked second link in uitableview.

- (void)viewDidLoad {
        [s         


        
5条回答
  •  醉酒成梦
    2021-01-31 09:33

    It's wise to verify first if the key is being observed or not before removing the observer with a @try @catch, like so:

    @try {
        [self.player removeObserver:self forKeyPath:@"status" context:nil];
    } @catch (id anException) {
        //do nothing, obviously it wasn't attached because an exception was thrown
        NSLog(@"status key not being observed");
    }
    

提交回复
热议问题