Objective-C type downcasting

Viewed 851

I am trying to override

- (void)makeWindowControllers;

Here is the code for it:

NSStoryboard* const storyboard = [NSStoryboard storyboardWithName:@"Main" bundle:nil];
NSWindowController* const windowController = [storyboard instantiateControllerWithIdentifier:@"Document Window Controller"];

And then I would like to add an image to ViewController that user has selected through open... in Swift I would simply do:

(windowController.contentViewController as? ViewController)?.imageView?.image = openedImage

How I could do this downcasting in Objective-C? I really got confused since I haven't done much type converting while I was learning C. Thanks.

1 Answers
[[((ViewController *)[windowController contentViewController]) imageView] setImage: openedImage];
Related