xcode 无法插入新操作连接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7176364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not insert new action connection Error
提问by GeRyCh
I get this error, when try to create new action for UIButton by dragging blue arrow from UIButton to my header file (you know, this new feature of XCode 4...)
我收到此错误,当尝试通过将蓝色箭头从 UIButton 拖动到我的头文件来为 UIButton 创建新操作时(您知道,XCode 4 的这个新功能......)
When I create action in code by myself and connect it in old way, simply by dragging from button to File's Owner, it's works well
当我自己在代码中创建动作并以旧方式连接它时,只需从按钮拖动到文件的所有者,它运行良好
Here's screenshot:
这是屏幕截图:
采纳答案by Mundi
Make sure your .m file exists in the project and on disk. Make sure it is correct with an @implementaiton
-@end
block. Open it in Xcode, close it, if the error persist, restart Xcode.
确保您的 .m 文件存在于项目和磁盘上。使用@implementaiton
-@end
块确保它是正确的。在Xcode中打开它,关闭它,如果错误仍然存在,重新启动Xcode。
Xcode is trying to write to EditPUViewController.m
(in the dealloc
method etc.) but could not find it.
Xcode 正在尝试写入EditPUViewController.m
(在dealloc
方法等中)但找不到它。
Also, it always helps to hard-clean the project with ?+?+?+K.
此外,它总是有助于硬清洁与项目?+ ?+ ?+ K。
回答by Rusy
Try this:
尝试这个:
Open Organizer then Project Tab.
打开管理器,然后打开项目选项卡。
Clear the "Derived Data". Xcode should re-index your project then and code sense should work. At least worked for me.
清除“派生数据”。Xcode 应该重新索引你的项目,代码感知应该可以工作。至少对我有用。
回答by Roger
I had a comparable problem when trying to connect an action. To solve it I manually added the IBAction and then XCode allowed me to connect from the button to the code.
尝试连接操作时,我遇到了类似的问题。为了解决这个问题,我手动添加了 IBAction,然后 XCode 允许我从按钮连接到代码。
回答by aks
Go to Xcode -> preferences -> location tab -> derived data -> clear derived dat.
转到 Xcode -> 首选项 -> 位置选项卡 -> 派生数据 -> 清除派生数据。
回答by Mischa
I ran into this issue myself but none of the methods presented here worked for me. The error described in the question above occurred when I tried to create an IBAction
in my view's header file (.h), whereas to my implementation file (.m) I couldn't even drag a line. (Xcode wouldn't even show this little popup where you can name your action.)
我自己遇到了这个问题,但这里介绍的方法都不适合我。当我试图IBAction
在我的视图的头文件 (.h) 中创建一个时,上述问题中描述的错误发生了,而对于我的实现文件 (.m),我什至无法拖动一条线。(Xcode 甚至不会显示这个小弹出窗口,您可以在其中命名您的操作。)
After trying for hours I figured that the reason why I couldn't create the IBAction
was because I had removed the very last line from my .m file. Xcode automatically adds an extra empty line after the @end
delimiterwhen you create a new Objective-C file.
尝试了几个小时后,我发现我无法创建的原因IBAction
是因为我已经从我的 .m 文件中删除了最后一行。当您创建新的 Objective-C 文件时,Xcode 会自动在@end
分隔符后添加一个额外的空行。
Don't ask me why - but if you remove that line Xcode doesn't let you create any actions or outlets. (This is obviously an Xcode bug.)
不要问我为什么 - 但是如果您删除该行,Xcode 将不会让您创建任何 actions 或 outlet。(这显然是一个 Xcode 错误。)
回答by A_B
I recently came across this problem. I soon realized that the cause had been my own doing. I had previously disabled XCode indexing (which used to take forever & eat up my RAM), using the below code in a terminal window:
我最近遇到了这个问题。我很快意识到原因是我自己做的。我以前在终端窗口中使用以下代码禁用了 XCode 索引(这曾经永远占用我的 RAM):
defaults write com.apple.dt.XCode IDEIndexDisable 1
To revert XCode to its default state, i used the following line in a terminal window:
要将 XCode 恢复到其默认状态,我在终端窗口中使用了以下行:
defaults write com.apple.dt.XCode IDEIndexDisable 0
Voila! All's well again..
瞧!又好了。。
回答by A.S.
I noticed that .m file was moved inside en.lproj folder.
我注意到 .m 文件被移动到 en.lproj 文件夹中。
Just delete (reference only) the .m file from the Xcode and moved .m out of the en.lproj. Add it again.Don't worry, you will get all your connections back.
只需从 Xcode 中删除(仅供参考).m 文件并将 .m 移出 en.lproj。再次添加。别担心,您将恢复所有连接。
It will fix the issue.
它会解决这个问题。
回答by Gordon Glas
I got the same error. Restarting Xcode did not fix it for me (I didn't want to reboot). The file was also not in the en.lproj folder (nor in the usual project folder after I deleted it from within Xcode). The fix for me was to re-create the file with a different name (Using different case in the filename alone was not enough to fix it... must be a different name entirely).
我得到了同样的错误。重新启动 Xcode 并没有为我修复它(我不想重新启动)。该文件也不在 en.lproj 文件夹中(在我从 Xcode 中删除它之后,也不在通常的项目文件夹中)。对我来说,修复方法是用不同的名称重新创建文件(仅在文件名中使用不同的大小写不足以修复它......必须完全不同的名称)。
回答by Eir
I ran into this problem when I created a class, deleted it and then created a new one with the same name. The workaround was not to reuse the name of the deleted class, but use a new one. Thus, I'd say it's a bug on the XCode side.
我在创建一个类时遇到了这个问题,删除了它,然后创建了一个同名的新类。解决方法不是重复使用已删除类的名称,而是使用新的名称。因此,我会说这是 XCode 方面的一个错误。
回答by Shinigamae
- Remove the newly created class (don't delete it, just remove link and then re-add it);
- Save Xib file;
- Restart Xcode;
- You may want to delete Derived Data as well if it does still not work.
- 删除新创建的类(不要删除,删除链接然后重新添加即可);
- 保存 Xib 文件;
- 重启Xcode;
- 如果派生数据仍然不起作用,您可能还想删除它。
This seems because of XCode is missing reference or need to refresh manually.
这似乎是因为 XCode 缺少引用或需要手动刷新。