gpt4 book ai didi

objective-c - 自定义类 NSObject 不符合键值编码

转载 作者:行者123 更新时间:2023-12-02 06:37:54 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why is my object not key value coding-compliant?

我有一本字典,我想将键/值添加到自定义类,但我总是收到错误,该类不符合 KVC,但 Apple 文档声明它应该是。

我的代码:

联系人对象.h:

@interface ContactObject : NSObject
+ (ContactObject *)testAdding;
@end

ContactObject.m:

@implementation ContactObject

- (id)init {
self = [super init];
if (self) {
// customize

}

return self;

}

+ (ContactObject *)testAdding
{
// create object
ContactObject *theReturnObject = [[ContactObject alloc] init];

[theReturnObject setValue:@"Berlin" forKey:@"city"];
[theReturnObject setValue:@"Germany" forKey:@"state"];

return theReturnObject;

}

@end

我想我错过了一些非常愚蠢的东西:)

拜托,感谢任何帮助......

您好,马蒂亚斯

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