1

I have an object (testSession) that complies to NSCoder and when I use:

[NSKeyedArchiver archiveRootObject:testSession toFile:filename];

It has:

@interface Session : NSObject <NSCoding> {

and has encodeWithCoder: and initWithCoder: functions. Neither are getting called. What would prevent this?

- (void)encodeWithCoder:(NSCoder *)encoder
- (id)initWithCoder:(NSCoder *)decoder

Do these need to be declared in the header?

2
  • Since your class conforms to the NSCoding protocol, you do not need to declare the methods in your header. Commented Sep 20, 2010 at 19:40
  • I haven't been. So what would prevent encodeWithCoder: from being called? Commented Sep 20, 2010 at 19:41

1 Answer 1

1

WHOOPS! I forgot to retain my testSession object after creating it. I'm a tad rusty :P

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.