Vidux
Vidux

Reputation: 303

Objective-C type downcasting

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.

Upvotes: 3

Views: 1301

Answers (1)

Vidux
Vidux

Reputation: 303

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

Upvotes: 2

Related Questions