0

I am trying to save an NSMutableArray in CoreData. The Array contains objects NSDictionary

NSDictionary has following Structure

valueDict = 
{
    FloorId = F0001;
    endCoordinates = "NSPoint: {541, 413}";
    linePath = "<UIBezierPath: 0x1d0903c0>";
    pointsOnLine =     (
    );
    startCoordinates = "NSPoint: {418, 504}";
},

To write to the Core Data I use following code: parray is type BinaryData

points.parray = [NSKeyedArchiver archivedDataWithRootObject:self.locationsArray];

and to retrieve value I use

locationsArray = [NSKeyedUnarchiver unarchiveObjectWithData:points.parray];

When I try to retrieve it i get following error :

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDictionary initWithObjects:forKeys:]: count of objects (0) differs from count of keys (5)'

I have checked that NSArray and NSDictionary adopts NSCoding protocol. What am I doing wrong here ?

ila
  • 920
  • 12
  • 35

1 Answers1

0

The best way to solve this is to create either a small test app, or a test method called when your app launches. Create a typical dictionary using the same keys and types, try to archive it, log the data size, then immediately try to unarchive the data. Assuming it fails comment out one or more keys til what's left works. Now you know the problem key and can better determine what is wrong.

David H
  • 40,852
  • 12
  • 92
  • 138