[英]The operation couldn’t be completed. (Cocoa error 1560.)
i am using core data in my application. 我在我的应用程序中使用核心数据。
i am getting this error when using transformable attribute to store NSArray. 我使用transformable属性存储NSArray时收到此错误。
in short i want to know, what should i do to store NSArray into core data. 总之,我想知道,我该怎么做才能将NSArray存储到核心数据中。
and how to retrive it. 以及如何回顾它。
this is my code. 这是我的代码。
#import <CoreData/CoreData.h>
@class category;
@interface qrandom : NSManagedObject
{
}
@property (nonatomic, retain) NSArray* arr;
@property (nonatomic, retain) category * cid;
@end
........................................................................................... .................................................. .........................................
#import "qrandom.h"
#import "category.h"
@implementation qrandom
@dynamic arr;
@dynamic cid;
@end
................................................................... .................................................. .................
category.h file category.h文件
#import <CoreData/CoreData.h>
@class qrandom;
@interface category : NSManagedObject
{
}
@property (nonatomic, retain) NSNumber * cid;
@property (nonatomic, retain) qrandom * randomrelation;
@end
.................................................................................... .................................................. ..................................
category.m file category.m文件
#import "category.h"
#import "qrandom.h"
@implementation category
@dynamic cid;
@dynamic randomrelation;
@end
................................................................................ .................................................. ..............................
Basically directly storing an NSArray
or an NSDictionary
as a transformable attribute won't work in CoreData because it will be unable to retrieve the array's values. 基本上直接存储
NSArray
或NSDictionary
作为可转换属性在CoreData中不起作用,因为它将无法检索数组的值。
See Marcus's answer which suggests just using relationships: 请参阅Marcus的回答,其中建议仅使用关系:
NSMutableArray stored with core data = WORKS, but after changing array DOESN'T WORK NSMutableArray与核心数据= WORKS一起存储,但在更改数组后不能正常工作
BUT! 但!
You can archive your array so that it CAN be used in your managed object. 您可以归档阵列,以便可以在托管对象中使用它。 See jbrennan's response here: Saving an NSMutableArray to Core Data
请参阅jbrennan的回复: 将NSMutableArray保存到Core Data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.