我想检查一个变量什么时候是僵尸,当它不是时,我有这样的功能,如果它真的存在,你必须从超级层中删除,有时它已经被删除了,但是作为一个僵尸,它正在崩溃在这一点上。我应该怎么做才能在运行时检查变量是否是僵尸?
if (avPlayerLayer) {
[avPlayerLayer removeFromSuperlayer];
}
我有这个代码来创建它:
if (!avPlayer) {
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
} else {
[avPlayer replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:movieURL]];
avPlayer.rate = 0.0f;
}
}
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
我应该做这样的事情吗?
if (!avPlayer) {
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
} else {
avPlayer = nil;
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
avPlayer.rate = 0.0f;
}
}
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
有什么帮助吗?先感谢您!