我是初学者,正在使用Core Data for iOS.我正在尝试在这里创建一个库函数,但是我收到了这条消息:
'NSInvalidArgumentException', reason:
'Unacceptable type of value for ordered to-many relationship: property
= "studenthistory"; desired type = NSOrderedSet; given type = __NSSetI;
value = {(
<NSManagedObject: 0x8cacd20> (entity: StudentHistory; id: 0x8cacd80
<x-coredata:///StudentHistory/tE710FEAD-C78E-4C91-8F38-23BDC5AA2C943> ;
data: {
bookid = 5;
checkin = 6;
checkout = 7;
open = TBA;
student = nil;
Run Code Online (Sandbox Code Playgroud)
关系是学生 - >(对许多人) - > StudentHistory.
我只能猜测,但我怀疑问题正在发生,试图设置一个对象,而期待更多,因为它是一个NSSet?
这是代码:
...
StudentHistory *stuhist = [NSEntityDescription insertNewObjectForEntityForName:@"StudentHistory" inManagedObjectContext:self.managedObjectContext];
stuhist.bookid = _bookidTextField.text;
stuhist.checkout = _checkoutTextField.text;
stuhist.checkin = _checkinTextField.text;
stuhist.open …Run Code Online (Sandbox Code Playgroud)