无法将操作:连接到NSApplication类的目标 [英] Could not connect the action : to target of class NSApplication

查看:79
本文介绍了无法将操作:连接到NSApplication类的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自可可触摸背景,有一点我坚持,我试图从头创建一个ViewController,并连接对象在我的XIB的动作在我的新ViewController。我将文件的所有者更改为我的ViewController并添加了插座,编译器似乎对我所做的感到满意。

I come from a Cocoa touch background and there's one point I'm stuck on, I'm trying to create a ViewController from scratch and connect objects in my xib to actions in my new ViewController. I changed the file's owner to my ViewController and added outlets, and the compiler seems to be happy with what I've done.

但是当我运行我的应用程序时,连接似乎失败了:无法连接动作开始:到NSApplication类的目标,但这个NSApplication引用隐藏在哪里?据我所知,我的ViewController有一个类NSViewController。

But when I run my application, the connections seem to fail with: 'Could not connect the action start: to target of class NSApplication,' but where is this NSApplication reference hiding? To the best of my knowledge my ViewController has a class of NSViewController.

ViewController : NSViewController


推荐答案


我将文件的所有者更改为我的ViewController,编译器似乎对我做的很满意。

I changed the file's owner to my ViewController and added outlets, and the compiler seems to be happy with what I've done.

当然,编译器不会在意 - 这是一个运行 - 时间错误。它听起来像你在MainMenu.xib文件中工作。该文件由应用程序对象加载。即使您在.xib中更改了文件所有者的类型,加载.xib的对象仍然是应用程序。

Sure, the compiler won't care -- this is a run-time error. It sounds like you're working in your MainMenu.xib file. That file is loaded by the application object. Even though you changed the type of File's Owner in the .xib, the object that's loading the .xib is still the application.

您可能需要创建一个单独的.xib文件供您的视图控制器加载。您可以在 文件中将文件所有者的类型更改为查看控制器类!将文件的所有者挂钩,它应该工作正常,因为您的视图控制器将是加载文件的对象。

You'll probably want to create a separate .xib file for your view controller to load. You change the type of File's Owner in that file to you view controller class! hook things up to File's Owner, and it should work fine since your view controller really will be the object that's loading the file.

这篇关于无法将操作:连接到NSApplication类的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆