对如何为 cocoa 应用程序实施视图控制器感到困惑

Confused with how to implement view controller for cocoa app

我是 objective-c 和 cocoa(今天开始)的新手,我有 java 的经验,这似乎是一个不同的世界。我正在构建一个带有场景工具包和 OSRSerialPort(Have looked at the example code and don't understand how the controller is connected to the view). The goal of this is to take accelerometer data from a micro controller and making a visual representation of it with scene kit. I've tried to implement my controller in the same way as the example project in OSRSerialPort's github. Mine just doesn't seem to work. I'm just confused on why my project would don't receive input from the port but the example one receives it just fine when I feel as I've implemented it the correct way. I've attached the xCode project here.

的应用

希望得到任何帮助。

I'm building an app with scene kit and OSRSerialPort(Have looked at the example code and don't understand how the controller is connected to the view)

使用 Xcode,您可以将控制器连接到视图 ,而无需编写任何代码。当您使用 Xcode 的 Interface Builder(IB) 时,几乎不可读的 xml 数据会自动插入到 window 的 .xib 文件中,这是实际连接的代码两个对象。

然后当您的应用程序启动时,将解析 .xib 文件,创建 .xib 文件中列出的对象并设置 .xib 文件中列出的连接。

我猜你找不到的连接在 window 的 .xib 文件中。

事实上,ORSSerialPort 的 README.md 是这样说的:

This application demonstrates that it is possible to setup and use a serial port with ORSSerialPort without writing a lot of "glue" code. Nearly all of the UI is implemented using Cocoa bindings.

无需编写大量 "glue" 代码 意味着开发人员无需编写代码,而是在 IB 中的对象之间进行大量拖动。而Cocoa bindings是一个艺术术语,但你会发现你必须先了解其他的东西。

弄清楚如何下载项目并在 Xcode 中本地打开它后,我能够在 IB 中查看 MainMenu.xib。下面是 MainMenu.xib 在 IB 中的屏幕截图,右侧是 ORSSerialPortDemoController 的部分连接列表:

这些连接是在没有编写任何代码的情况下建立的。

I'm very new to objective-c and cocoa(started today)

好吧,那就把你当前的项目放在一边,学习如何在 Hello World 风格的应用程序中使用 Xcode 的基础知识,然后继续前进。随着学习的进步,您会知道何时可以返回当前项目。