作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试覆盖
- (void)makeWindowControllers;
这是它的代码:
NSStoryboard* const storyboard = [NSStoryboard storyboardWithName:@"Main" bundle:nil];
NSWindowController* const windowController = [storyboard instantiateControllerWithIdentifier:@"Document Window Controller"];
然后我想将图像添加到 ViewController
用户通过 open...
在 Swift 中选择的图像我会简单地做:
(windowController.contentViewController as? ViewController)?.imageView?.image = openedImage
我如何在 Objective-C 中进行这种向下转换?我真的很困惑,因为我在学习 C 时没有做过太多类型转换。谢谢。
最佳答案
[[((ViewController *)[windowController contentViewController]) imageView] setImage: openedImage];
关于Objective-C 类型的向下转型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53020655/
在Java编程中经常碰到类型转换,对象类型转换主要包括向上转型和向下转型。 向上转型 我们在现实中常常这样说:这个人会唱歌。在这里,我们并不关心这个人是黑人还是白人,是成人还是小孩,也就是说我们
当使用使用 C 风格继承的 C API 时,(利用 C 结构的标准布局),例如 GLib ,我们通常使用 C 风格的转换来向下转换: struct base_object { int x;
我是一名优秀的程序员,十分优秀!