简体   繁体   中英

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.

in short i want to know, what should i do to store NSArray into core data.

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

#import <CoreData/CoreData.h>

@class qrandom;

@interface category :  NSManagedObject  
{
}
@property (nonatomic, retain) NSNumber * cid;
@property (nonatomic, retain) qrandom * randomrelation;

@end

....................................................................................

category.m file

#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.

See Marcus's answer which suggests just using relationships:

NSMutableArray stored with core data = WORKS, but after changing array DOESN'T WORK

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM