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

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

Answers


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


Need Your Help

Add a css class to an element if the element has a certain text via javascript

javascript jquery html css

I need to add the class .active-trail to an li element if the li element has a link (a) as a child element containing the word "Help".

How can I transplant the OSX's LookAndFeel to other type of systems in Java

java macos look-and-feel

I Set the LookAndFeel to be System, And I found that it looks pretty in OSX system. Like this: