ios 此类不符合键值 XXXXXX 的键值编码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5930492/
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
this class is not key value coding-compliant for the key XXXXXX
提问by Luca
when i try to build and run my app, it crashes and i got this in the log :
当我尝试构建和运行我的应用程序时,它崩溃了,我在日志中得到了这个:
reason: '[<LoadingViewController 0x6b2c5a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aproposViewController.'
the strange is that aproposViewController
is not used in LoadingViewController
, it's just another view controller in my app. please help, thx in advance :)
奇怪的是它aproposViewController
没有在 中使用LoadingViewController
,它只是我应用程序中的另一个视图控制器。请帮忙,提前谢谢:)
EDIT
编辑
appdelegate.h :
appdelegate.h :
@class LoadingViewController;
@interface TopStationAppDelegate : NSObject <UIApplicationDelegate,CLLocationManagerDelegate> {
UIWindow *window;
LoadingViewController *loadingView;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LoadingViewController *loadingView;
@end
appdelegate.m:
appdelegate.m:
#import "LoadingViewController.h"
@implementation TopStationAppDelegate
@synthesize window;
@synthesize loadingView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:loadingView.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[loadingView release];
[window release];
[super dealloc];
}
@end
there is no declaration of aproposViwController, even in IB for the main view !!
EDIT 2here two screenshot of my besic set in the main and loadingView in interface builder :
没有 aproposViwController 的声明,即使在主视图的 IB 中!
在这里编辑 2我在界面构建器中的主界面和加载视图中设置的两个屏幕截图:
回答by kball
Can't be sure if this is what's happening in your case, but you'll commonly see this message if you have a connection set up in your nibs to assign an object to a property of another object, but the property is missing on the target object.
无法确定这是否是您的情况,但是如果您在笔尖中设置了一个连接以将一个对象分配给另一个对象的属性,但您通常会看到此消息,但该属性在目标对象。
So you might have had an IBOutlet named aproposViewController on LoadingViewController at one point, connected another view controller to it in the nib, and then removed the IBOutlet but neglected to remove the connection in the nib.
因此,您可能曾经在 LoadingViewController 上有一个名为 aproposViewController 的 IBOutlet,在笔尖中将另一个视图控制器连接到它,然后删除了 IBOutlet 但忽略了删除笔尖中的连接。
So when the nib is loaded, it tries to set the property, only to find it doesn't exist, hence:
因此,当加载笔尖时,它尝试设置该属性,却发现它不存在,因此:
reason: '[<LoadingViewController 0x6b2c5a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aproposViewController.'
回答by Eagerbvr
I had this problem and it was because I had an:
我遇到了这个问题,这是因为我有一个:
vc = [[someVC alloc] initWithNibName:@"oldNibFileNameButCachedSomewhereWithOldRefToPropertyIn" bundle:nil];
回答by Navnath Godse
If you removed the connection to IBOutlet from XIB and still it happens
如果您从 XIB 中删除了与 IBOutlet 的连接,但它仍然发生
Then delete the app from simulator and run again.
然后从模拟器中删除应用程序并再次运行。
回答by Narasimha Nallamsetty
I have found the same error in my Application and I found solution for this after some time.
我在我的应用程序中发现了同样的错误,一段时间后我找到了解决方案。
Actually I Have given 2 action events for one button. I have removed extra connection which is assigned to button after that the problem is over.
实际上,我已经为一个按钮提供了 2 个动作事件。问题结束后,我删除了分配给按钮的额外连接。
This is worked in my scenario. I hope it will be helpful to someone else..
这在我的场景中有效。我希望它会对其他人有所帮助..