viewDidLoad: _view.device = MTLCreateSystemDefaultDevice(); crashes

Hi,
Code Block obj-c
- (void)viewDidLoad
{
    [super viewDidLoad];
    _view = (MTKView *)self.view;
    _view.device = MTLCreateSystemDefaultDevice(); // <- Error
.
.
.
}

with Xcode 9.3 it runs normal with 12.4 I get the note:


 Failed to set (contentViewController) user defined inspected property on (NSWindow): -[NSView setDevice:]: unrecognized selector sent to...

Mit freundlichen Grüßen
Uwe





Replies

You expect self.view as an MTKView, but it actually is a plain NSView and that is causing the issue.
How have you set up the storyboard (or nib) of the view controller?
@OOPer
I changed the project format to 9.3 and the Error disappeared. I changed back to 12.4 : No error.
I know almost nothing about Metal and I hope the community help me when i stuck in the future.
Uwe

I changed the project format to 9.3 and the Error disappeared. I changed back to 12.4 : No error.

Seems you can go forward, even the real cause of the issue unknown.

I hope the community help me when i stuck in the future.

If you can describe the issue precisely, readers can easily help solving it. Good luck.