-3

I tried:

NSData *data = [NSKeyedArchiver archivedDataWithRootObject:dictionary];

    BOOL success = [data writeToFile:entryPath atomically:YES];

But for whatever reason, it crashed with this error:

2012-03-24 20:06:13.550 Journal[1348:707] -[JEntry encodeWithCoder:]: unrecognized selector sent to instance 0x25d1a0
2012-03-24 20:06:13.553 Journal[1348:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JEntry encodeWithCoder:]: unrecognized selector sent to instance 0x25d1a0'

How else do i save an NSObject subclass to a file?

Andrew
  • 15,935
  • 28
  • 121
  • 203

1 Answers1

3

You need to implement encodeWithCoder: in your JEntry class if you want NSArchiver to work. You will probably want initWithCoder:, too, so that you can deserialize later.

Read the Archives and Serializations Programming Guide to get started.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469