I would like to check when a variable is a zombie & when it is not, i have function like this one, where y have to remove from superlayer if it actually exist, sometimes it is removed already, but being a zombie, it is crashing in this point. What should I do in order to check if the variable is a zombie or not at runtime?
if (avPlayerLayer) {
[avPlayerLayer removeFromSuperlayer];
}
I have this code to create it:
if (!avPlayer) {
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
} else {
[avPlayer replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:movieURL]];
avPlayer.rate = 0.0f;
}
}
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
Should I do something like this instead?:
if (!avPlayer) {
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
} else {
avPlayer = nil;
avPlayer = [[AVPlayer alloc] initWithURL:movieURL];
avPlayer.rate = 0.0f;
}
}
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
Any help? thank you in advance!
Why not set the variable to nil instead, and then check for nil.