此类不是键值screenNumber的键值编码兼容

时间:2014-07-21 18:50:35

标签: ios objective-c uiviewcontroller crash uncaught-exception

我有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参考?我不排除我过去可能已经使用过这个变量而已经不再使用过了。

谢谢

1 个答案:

答案 0 :(得分:0)

好的,发现了这个问题。模拟器中仍然有旧文件。删除主页/首选项/应用程序支持/ iPhone模拟器/ 7.1 /应用程序/.