gpt4 book ai didi

ios - AppDelegate:此类与键的键值编码不兼容---

转载 作者:行者123 更新时间:2023-11-29 11:56:48 27 4
gpt4 key购买 nike

AppDelegate.h我创建了以下属性,

@property (strong, nonatomic) NSMutableDictionary *googleUserDetailsDictionary;

AppDelegate.m ,

static NSString *kGoogleDetails = @"googleDetails";
@synthesize googleUserDetailsDictionary;

我在 AppDelegate.m 中创建了一个自定义方法我在其中添加了以下行: [self setValue:googleUserDetailsDictionary forKey:kGoogleDetails];

在我想成为 googleUserDetailsDictionary 的观察者的 ViewController 中属性(property),

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate addObserver:self forKeyPath:@"googleUserDetailsDictionary" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:kGoogleDetails]) {
NSLog(@"This is change taking place: %@ \t\t", change);

}
}

然后,当我尝试打开 ViewController 时,出现以下错误: ** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FIRA_AppDelegate-1470253453284 0x7fd4fa839410> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key googleDetails.'

最佳答案

我相信它告诉你真相。您没有任何名为 googleDetails 的属性。

尝试更改 key 路径以匹配属性,例如:

static NSString *kGoogleDetails = @"googleUserDetailsDictionary";

关于ios - AppDelegate:此类与键的键值编码不兼容---,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38752162/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com