I am a fan of the guard
statements using Swift.
One thing I haven't fully understand is how (or even if) to use it inside a func
tion that expect return value.
Simple example:
func refreshAudioMix() -> AVPlayerItem? {
guard let originalAsset = rootNC.lastAssetLoaded else {
return nil
}
let asset = originalAsset.copy() as! AVAsset
..... return AVPlayerItem ....
}
The issue with this approach is that I need to check the returned value each time. I am trying to understand if am I approaching this correctly or maybe even guard
not needed here at all.
Thank you!