如果不使用 NSViewController 来兼容 10.4,你会怎么做?

发布于 2024-08-08 01:25:27 字数 164 浏览 11 评论 0原文

我需要做的就是在窗口的 NSView 中加载和交换一些笔尖。我知道如何使用 NSViewController 做到这一点,并让它在 10.5-10.6 中完美工作,但我不知道在 10.4 中该怎么做。

非常欢迎教程链接,我很难找到遗留的东西。

(是的,我确实需要支持 10.4。)

All I need to do is load and swap some nibs in a NSView of a window. I know how to do it with NSViewController and have it working perfectly with 10.5-10.6, but I don't know what to do for 10.4.

Tutorial links very welcome, I have trouble finding legacy stuff.

(Yes, I really do need to support 10.4.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原来是傀儡 2024-08-15 01:25:27

通过在 Leopard 中使用 NSViewController,我可以告诉您它的功能非常基本,您应该能够以相当小的努力来复制它。

本质上,它有一个 view 属性/出口和一个 initWithNibName:bundle: 方法。除此之外,它并没有做任何特别花哨的事情。它有一些方便的东西,比如采用 NSEditorrepresentedObject 属性。您应该能够在一两个小时内完成同等的课程。

现在,如果您这样做,您将放弃与更高版本的 Cocoa 的兼容性。最终,您可能会放弃 10.4 支持,而您将只剩下您的类和真正的 NSViewController。当发生这种情况时,我建议将您的自定义视图控制器重新建立在 Cocoa 的 NSViewController 上。如果您使用与 NSViewController 相同的名称/数据类型来命名属性,则只需删除您自己声明的属性和方法即可。

From working with NSViewController in Leopard, I can tell you that its functionality is very basic, and that you should be able to replicate it with fairly minimal effort.

Essentially, it has a view property/outlet, and an initWithNibName:bundle: method. Beyond that, it doesn't do anything especially fancy. It has some convenience things, like adopting NSEditor, and a representedObject property. You should be able to bang out an equivalent class in an hour or two.

Now, what you will give up if you do this is compatibility with later versions of Cocoa. Eventually, you'll probably drop 10.4 support and you'll be left with your class and the real NSViewController. When that happens, I'd recommend re-basing your custom view controller on Cocoa's NSViewController. If you've named the properties with the same names/data types as NSViewController, you should only have to drop the properties and methods you've declared yourself.

我早已燃尽 2024-08-15 01:25:27

使用 NSBundle 加载笔尖:

YourController *controller = [[YourController alloc] init];
BOOL success = [NSBundle loadNibNamed:@"YourNibName" owner:controller];

Use NSBundle to load the nib:

YourController *controller = [[YourController alloc] init];
BOOL success = [NSBundle loadNibNamed:@"YourNibName" owner:controller];
听,心雨的声音 2024-08-15 01:25:27

基本上,您编写自己的控制器类,它执行与 NSViewController 相同的操作。控制器类被添加到 AppKit 中,因为我们很多人一遍又一遍地编写本质上相同的代码。

Basically, you write your own controller class that does the same things that NSViewController does. The controller classes were added to the AppKit because so many of us were writing essentially the same code over and over.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文