即使接口生成器是一个MyClass,我得到一个错误时启动应用程序。

当MyClass是库的一部分时,就会发生这种情况,如果直接在应用程序目标中编译该类则不会发生这种情况。


当前回答

这里有很多答案,但没有一个是解决方案, 我追踪到storyBoard,控制器有一个无效的自定义类(类不存在后,我重命名它)

其他回答

这里有很多答案,但没有一个是解决方案, 我追踪到storyBoard,控制器有一个无效的自定义类(类不存在后,我重命名它)

我终于解决了这个问题,我忘记在我的.m文件中添加以下代码:

@implementation MyTableViewCell

@end

所以这是因为我为我的表格单元格做了一个占位符@interface,它有一个连接到.xib文件中的元素,但在Interface Builder中有一个错误,如果没有为一个类指定@implementation,它就找不到它。

我已经完成了从其他论坛查看.xib作为源代码和查看MyTableViewCell的所有步骤,尽管我已经将它注释出了我的代码。我试过重置模拟器。我甚至尝试将所有的类分解为与接口同名的单独文件,但在此之前都不起作用。

附注:根据我的经验,.h/。M文件与@interface的名称不同。我有几个文件包含不止一个@interface,他们工作得很好。

P.P.S.我有一个更详细的解释,为什么UITableViewCell和UICollectionViewCell导致这个错误在https://stackoverflow.com/a/22797318/539149以及如何揭示它在编译时使用registerClass: forCellWithReuseIdentifier:。

从接口生成器/故事板被引用到一个不可用的类。

如果是已知类,则没有链接。

如果不是一个类,或者只是一些字符,则可能是打字错误。 在这种情况下,检查视图控制器中这个'unknown class'的所有字段。 在“身份检查器”中(块“自定义类”左起第三个)是一个字段 '类',其中可能包含错误的值。通常它会列出字段类型 (UIView / UILabel等)。

In my case I got this error because I'd tried to save some work by creating a new project and then deleting several of the source files and copying over the source files of the same name from the working project. I also copied my MainStoryBoard file which was looking for my RootViewController. However, when I had deleted the original RootViewController and then added in the RootViewController from the previous product, evidently the Add Files operation failed to "check" the target box as suggested above. By merely visting all of the newley imported ".m" files and making sure that the target membership box was checked, all was well. I think what was happening was that the storyboard file was looking for a class that had been "excluded" from the link because the target membership was unchecked. Making sure the required files for the target are so designated in the target membership in the file inspector did the trick. Thanks Pat! (see above)

在我的例子中,我有XCode6,指定的类.m文件最终在构建阶段的错误位置-它应该在编译源下,但最终在