【发布时间】:2014-07-21 18:50:35
【问题描述】:
我有 2 台计算机在 Xcode 中运行相同的 iOS 代码(在 Dropbox 文件夹中)。
创建 UIViewController 时,它在另一台机器上正常工作,而另一台机器给出:这个类对于键 screenNumber 不符合键值编码。
我在代码中绝对没有对 screenNumber 的引用,并且没有为这个特定的类使用任何情节提要和 xib。
初始化视图的命令:
ChildViewController *childViewController = [[ChildViewController alloc] initWithIndex:index :100];
它在这段代码中的随机位置崩溃:
-(ChildViewController *)initWithIndex:(int)index :(int)maximumIndex
{
self = [super init];
if (self)
{
NSLog(@"Init child:%d",index);
// Custom initialization
self.index=index;
maxIndex=maximumIndex;
}
return self;
}
ChildViewController 派生自 UIViewController。
收到的错误消息是:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ChildViewController 0x8e0f4d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key screenNumber.'
知道我是否可以在项目目录中没有的另一个文件夹中找到 screenNumber 引用?我不排除我过去可能使用过这个变量,但现在不再使用了。
谢谢
【问题讨论】:
-
而异常堆栈在失败时是什么样子的? exact 异常消息是什么。
-
要回答以上问题,请进入Breakpoint Navigator并启用异常断点(点击左下角的加号
+角)。 -
嗨,childviewcontroller 是从什么派生的?是否有必须绑定的 iboutlet?也许你在这里找到答案:stackoverflow.com/questions/5930492/…
-
您可以使用 extern 关键字将信息从一个项目排除到另一个项目。
-
更改了有问题的文本。现在描述错误消息,并且 ChildViewController 是从 UIViewController 派生的。
标签: ios objective-c uiviewcontroller crash uncaught-exception