ios 无法插入新的插座连接错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10996023/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:43:56  来源:igfitidea点击:

Could not insert new outlet connection error

iosobjective-cuitableviewcocoa-touchuikit

提问by Dale Myers

I have created a custom cell for loading into a table. The interface is complete and now I am trying to link the xib and the class.

我创建了一个用于加载到表格中的自定义单元格。接口已经完成,现在我正在尝试链接 xib 和类。

I have the split screen view open and I try to control drag the item so that Xcode can make the connection for me. When I fill in the name and click connect I get an error:

我打开了分屏视图,并尝试控制拖动该项目,以便 Xcode 可以为我建立连接。当我填写名称并单击连接时,出现错误:

Could not insert new outlet connection: Could not insert source code into document at URL://localhost/Users/Velox/Projects/CompanyName/ProjectName/ProjectName/HistoryCell.m because it does not contain a class definition for the class named HistoryCell.

无法插入新的插座连接:无法将源代码插入 URL://localhost/Users/Velox/Projects/CompanyName/ProjectName/ProjectName/HistoryCell.m 中的文档,因为它不包含名为 HistoryCell 的类的类定义。

I have set the custom class of the xib to HistoryCell.

我已将 xib 的自定义类设置为 HistoryCell。

What am I missing here?

我在这里缺少什么?

Thanks.

谢谢。

采纳答案by Dale Myers

So, it turns out that I was being a fool. You can't quite do it like this with Xcode. If you create the properties manually in the header file, then synthesise them in the class file, you can then link by doing the following:

所以,事实证明我是个傻瓜。你不能完全用 Xcode 做到这一点。如果在头文件中手动创建属性,然后在类文件中合成它们,则可以通过执行以下操作进行链接:

Open the xib file Right click on the cell in the "Objects" panel Click and drag from the options here to the objects on the xib.

打开 xib 文件 右键单击​​“对象”面板中的单元格单击并从此处的选项拖动到 xib 上的对象。

That's all there was to it.

这就是全部。

回答by codeburn

This problem seems to be an Xcode bug which creeps up mostly when you replace a file with a new file of the same name. Xcode seems to keep a reference of the older file of the same name.

这个问题似乎是一个 Xcode 错误,当您用同名的新文件替换文件时,该错误主要出现。Xcode 似乎保留了同名旧文件的引用。

Anyhow, the way to fix this seems to be -

无论如何,解决这个问题的方法似乎是 -

  1. Cleanthe project

  2. Click <Your Project> in Project Navigatorview. Go to Compile Sourcesunder Build Phasesof the target for which you are building. Remove and add back the .m file which is giving you trouble.

  3. Alternatively, in the File Inspector(Utilitiesview) of the NIB file, under Target Membership, uncheck and check back the target name.

  4. Restart Xcode for good measure.

  5. Of course, deleting and adding back the .m file alone should fix it too.

  1. 清理项目

  2. 单击“项目导航器”视图中的<您的项目> 。去编译源代码构建阶段,而您正在建设的目标。删除并添加回给您带来麻烦的 .m 文件。

  3. 或者,在NIB 文件的文件检查器实用程序视图)中,在Target Membership 下,取消选中并检查目标名称。

  4. 重新启动 Xcode 以获得良好的测量。

  5. 当然,单独删除并添加回 .m 文件也应该解决它。

Steps 1. and 2. alone fixed it for me. Feel free to ask if any step needs expanding.

步骤 1. 和 2. 单独为我修复了它。随意询问是否有任何步骤需要扩展。

Cheers and happy coding :)

干杯和快乐的编码:)

回答by Daniel Ryan

I fixed this issue by deleting the .m file (reference only) then adding it back in to the project. I think XCode gets corrupted at times (and I'm on the latest 4.6).

我通过删除 .m 文件(仅供参考)然后将其重新添加到项目中来解决此问题。我认为 XCode 有时会损坏(我使用的是最新的 4.6)。

回答by Elf Sundae

https://stackoverflow.com/a/16166878/521946

https://stackoverflow.com/a/16166878/521946

Try to clean your project and restart Xcode.
If it still cannot be connected, follow the Utilitiesnavigation view of Xcode, in the Target membershipsection, uncheck & checkthe checkbox, it will be work. Maybe you should rebuild the project after unchecking.

尝试清理您的项目并重新启动 Xcode。
如果仍然无法连接,请按照UtilitiesXcode的导航视图,在该Target membership部分中,取消选中并选中复选框,它将起作用。也许您应该在取消选中后重建项目。

回答by Abdul Rehman

  1. Remove .m file from compoile sources and add again.
  2. clean and build your project.
  3. Restart xcode.
  1. 从编译源中删除 .m 文件并再次添加。
  2. 清理并构建您的项目。
  3. 重启xcode。

In my case, #1 fixed the issue

就我而言,#1 解决了这个问题

回答by benaneesh

Quit XCode, then purge the derivedData using:

退出 XCode,然后使用以下命令清除衍生数据:

rm -rf ~/library/Developer/Xcode/DerivedData/*

Restart XCode and connect.

重新启动 XCode 并连接。

If you want, create an alias

如果需要,请创建别名

alias purgeallbuilds='rm -rf ~/library/Developer/Xcode/DerivedData/*'

in your .bash_profile as suggested here.

按照此处的建议在您的 .bash_profile 中。

回答by Fadi Abuzant

Just go to .mfile

只需转到.m文件

remove

消除

#import "calssName.h" 

save file

保存存档

add text again

再次添加文字

#import "calssName.h"

save file

保存存档

回答by Philip007

The problem could be caused by other errors. Build the program, if there are any errors or warnings, fix it. Then ctrl-drag to insert outlet again and the problem will go away.

该问题可能是由其他错误引起的。构建程序,如果有任何错误或警告,请修复它。然后ctrl-drag再次插入插座,问题就会消失。

回答by Ilker Baltaci

I had the same problem for a viewcontroller which was removed accidantly.I readded files to project but adding Outlets by draging with from xib file gave me the mentioned error.I cleaned the project and restarted XCode and everything worked fine again.

我有一个视图控制器的相同问题,它被意外删除。我将文件读取到项目,但通过从 xib 文件中拖动来添加 Outlets 给了我提到的错误。我清理了项目并重新启动了 XCode,一切又正常了。

回答by m_bernemann

I had the same issue with Xcode 6.2 In this case it was sufficient to 'touch' the target class - by adding and removing something meaningless - to force a recompile. The issue went away then.

我在 Xcode 6.2 中遇到了同样的问题。在这种情况下,“触摸”目标类就足够了——通过添加和删除一些无意义的东西——来强制重新编译。那个问题就消失了。