[英]NSArray from NSSet of objects crashes when calling 'allObjects'
I have an core data NSSet of objects through a relationship that I am trying to put into an array. 我通过尝试放入数组的关系获得了对象的核心数据NSSet。
When I call the 'allObjects' selector I get a crash on my object in the NSSet that the selector does not exist. 当我调用“ allObjects”选择器时,我在NSSet中的对象上崩溃了,选择器不存在。 Well, it obviously doesn't, but how do I get my data to copy into the array?
好吧,显然不是,但是如何将数据复制到数组中?
Heres the code that crashes. 这是崩溃的代码。
NSArray *items = [surveyCategory.surveyQuestions allObjects];
Inside my surveyQuestions NSSet are SurveyQuestion objects. 我的SurveyQuestions NSSet内部是SurveyQuestion对象。 And this throws the error
`[SurveyQuestion allObjects]: unrecognized selector sent to instance
这会引发错误
`[SurveyQuestion allObjects]: unrecognized selector sent to instance
Any ideas on how to fix this? 有想法该怎么解决这个吗?
thanks 谢谢
From the error message it looks as if surveyQuestions
is not a to-many relationship as you expect, but a to-one relationship, so that surveyCategory.surveyQuestions
is a SurveyQuestion
object and not a set. 从错误消息中,似乎
surveyQuestions
不是您期望的多对多关系,而是一对一的关系,因此surveyCategory.surveyQuestions
是SurveyQuestion
对象,而不是集合。
Perhaps you changed the Core Data model and did not re-create the managed object subclass file, so that the compiler did not complain. 也许您更改了核心数据模型,但没有重新创建托管对象子类文件,以便编译器不会抱怨。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.