I've looked at each posted question on this topic, but none give me a solution.
My project replicates to a large extent the AVPlayer demo app in the dev library (minus the scrubbing capabilities): I have a copy and paste AVPlayerDemoPlaybackView
class (renamed YOPlaybackView
) and an associated controller, along with a very similar xib (minus the scrubber).
My view controller code follows very closely the pattern in the demo (code differences only posted below for brevity).
I have ensured the view controller is the file's owner
I have made sure outlets are not duplicated
I have checked that the view controller is a valid instance by putting a breakpoint in
dealloc
The error occurs in the
observeValueForKeyPath
method when the current item for the player changes/will change. The following line gives the error "-[UIView SetPlayer:]": unrecognised selector sent to instance ..."[playbackView setPlayer:player];
If I create an instance of that view just prior to this call, I don't get the error:
YOPlaybackView* vw = [[YOPlaybackView alloc] init];
[playbackView setPlayer:player];
It seems to me that it might be something to do with nib lazy loading (and creating an instance kicks it in to life).
Looking in the debugger window, playbackView seems to be valid with and without the extra line that creates an (unused) instance.
Can anyone help progress my object/app lifecycle knowledge please?
Edit - in response to proposed answer containing IB comment
This is a snap of the IB, showing the view hierarchy and correctly named custom view in the inspector.
Edit - in response to question about valid SetPlayer
The view class in question looks like this:
@class AVPlayer;
@interface YOPlaybackView : UIView
@property (nonatomic, retain) AVPlayer* player;
- (void)setPlayer:(AVPlayer*)player;
@end
and impl:
@implementation YOPlaybackView
+ (Class)layerClass
{
return [AVPlayerLayer class];
}
- (AVPlayer*)player
{
return [(AVPlayerLayer*)[self layer] player];
}
- (void)setPlayer:(AVPlayer*)player
{
[(AVPlayerLayer*)[self layer] setPlayer:player];
}
@end
Edit - output log
2013-07-23 12:05:39.084 iOSVideoPlayerExample[8331:14003] Unknown class YOPlaybackView in Interface Builder file.
2013-07-23 12:05:39.956 iOSVideoPlayerExample[8331:14003] Unbalanced calls to begin/end appearance transitions for <YOMasterViewController: 0x985aa10>.
2013-07-23 12:05:40.428 iOSVideoPlayerExample[8331:14003] <UIView: 0x8383900; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x8381710>>
2013-07-23 12:05:40.429 iOSVideoPlayerExample[8331:14003] -[UIView setPlayer:]: unrecognized selector sent to instance 0x8383900
(lldb)