问题描述
我有一个简单的Core Data实体,它有一个名为description的字符串属性。
当程序命中时,程序崩溃:
valueForKey:@description
我将description属性更改为text,问题解决了。
为什么会发生这种情况?
description是Core Data中的保留关键字吗?
从NSObject调用描述方法?
如果存在这些保留的关键字,是否有引用?
解决方案因为它与
NSObject
中的-description
方法冲突Core Data动态生成属性访问器和mutator - 名为description的属性将需要创建一个名为-description
的访问器方法。这些记录在中, :
I have a simple Core Data entity that had a string attribute named "description". The program crashes when it hits:
valueForKey:@"description"
I changed the "description" attribute to "text" and problem solved.
Why does this happen?
Is "description" a reserved key word in Core Data?
Is it related to calling the description method from NSObject?
Is there a reference to these reserved key words if they exist?
解决方案Because it conflicts with the
-description
method inNSObject
(recall that Core Data dynamically generates property accessors and mutators — a property named ‘description’ would require creating an accessor method called-description
). This is documented in the Core Data Programming Guide and the NSPropertyDescription Class Reference:
这篇关于为什么我无法使用“说明”作为Core Data实体的属性名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!