Objective-C类型下垂

时间:2018-10-27 09:48:47

标签: objective-c xcode macos

我正在尝试覆盖

- (void)makeWindowControllers;

这是它的代码:

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

然后我想将图像添加到用户通过Swift中的ViewController选择的open...中,我只需做一下:

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

如何在Objective-C中进行向下转换?我真的很困惑,因为我在学习C时没有做太多类型转换。

1 个答案:

答案 0 :(得分:0)

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