简体   繁体   English

XCode正在尝试加载我从项目中删除的NIB文件

[英]XCode is attempting to load a NIB file that I deleted from the project

I started working on a view with a NIB file and decided to delete it from my project to build it programatically. 我开始使用NIB文件处理视图,并决定从我的项目中删除它以编程方式构建它。 There are no mentions of the supposed call to the NIB file in any of my code and the .XIB doesn't exist anywhere in any of the application directories. 在我的任何代码中都没有提到对NIB文件的调用,并且.XIB在任何应用程序目录中都不存在。 Here's the exact error being thrown at me from the debug console. 这是从调试控制台向我抛出的确切错误。

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:      
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "GESplitMainViewController"
nib but the view outlet was not set.' 

I cannot comprehend why the xcode is still attempting to load the NIB. 我无法理解为什么xcode仍在尝试加载NIB。

Firstly, the default implementation of initWithNibName:bundle searches the bundle for a nib that shares the same name as the view controller's class if you pass nil as the first parameter, which is why your app is trying to load one. 首先, initWithNibName:bundle的默认实现initWithNibName:bundle搜索一个与视图控制器类共享同名的nib,如果你将nil作为第一个参数传递,这就是你的应用尝试加载一个的原因。

The fact that it is finding one is probably because the .xib you used to have in your project is still included in the bundle that the simulator is running. 它找到一个的事实可能是因为你曾经在项目中拥有的.xib仍然包含在模拟器运行的包中。 Xcode has a habit of leaving deleted resources in the simulator bundle even if you delete them from your project. Xcode习惯于将已删除的资源保留在模拟器包中,即使您从项目中删除它们也是如此。

If you delete the app from the simulator, clean your Xcode project and run again, it should stop trying to load the nib. 如果从模拟器中删除应用程序,清理Xcode项目并再次运行,它应该停止尝试加载笔尖。

Although this is the reason your app is loading from a nib, it is not the reason it is crashing. 虽然这是您的应用程序从笔尖加载的原因,但这并不是它崩溃的原因。 The crash is because the old .xib you were using didn't have a view connected to the view controller's view outlet. 崩溃是因为您使用的旧.xib没有连接到视图控制器视图插座的视图。

如果你还没有在应用程序的任何地方使用nib名称,首先删除应用程序,清理你的构建并测试它,希望这能解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM