AVPlayer Front Class Declaration

So, I have this AVPlayerViewController nested in a container view in my storyboard. I am prepareForSegue controller of this player using prepareForSegue . But when I try to set any properties in the player property, Xcode gives me the error Receiver 'AVPlayer' for class message is a forward declaration . I correctly imported AVKit into .h . What am I doing wrong?

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"videoPlayerEmbed"]) { self.videoPlayerController = (AVPlayerViewController *)segue.destinationViewController; self.videoPlayerController.delegate = self; self.videoPlayerController.player = [[AVPlayer alloc] init]; } else { [super prepareForSegue:segue sender:sender]; } } 

+5
source share
2 answers

I get it. I thought that #import <AVKit/AVKit.h> enough for AVPlayerViewController, but if you want to control AVPlayer , you will also need #import <AVFoundation/AVFoundation.h> .

+21
source

Have you imported AVPlayerViewController.h ie #import "AVPlayerViewController.h" ?

A direct declaration is where you are trying to send messages to a class that the compiler is not aware of.

0
source

All Articles