Wednesday, April 6, 2011

Archive a NSMutableArray

I need to archive a NSMutableArray which is being controlled by an ArrayController. I tried this:

[NSKeyedArchiver archivedDataWithRootObject:array];

But I got this error:

*** -[NSKeyedArchiver dealloc]: warning: NSKeyedArchiver deallocated without having had -finishEncoding called on it.

How may I solve that please?

From stackoverflow
  • The root object of the graph you're archiving and anything referenced/contained by it must conform to < NSCoding > protocol. See Encoding and Decoding Objects for code examples for making your classes compliant (don't forget to "adopt" the protocol in your objects' interface declaration: @interface MyClass : NSObject < NSCoding >).

    Fernando Valente : Still no luck :(
    Joshua Nozzi : That doesn't help us help you. :-) Post your code and describe how it's not working.
    Fernando Valente : Sorry, I forgot. I got these error: 2010-02-28 22:22:18.145 My app[53732:a0f] -[content encodeWithCoder:]: unrecognized selector sent to instance 0x100189740 2010-02-28 22:22:18.146 My app[53732:a0f] -[content encodeWithCoder:]: unrecognized selector sent to instance 0x100189740
    Abizern : Might be a stupid question, but have you actually implemented the `encodeWithCoder:` method for the objects that are in the array?
    Fernando Valente : Yeah, I did that
    Joshua Nozzi : All this back-and-forth questioning would be completely unnecessary if you'd post the relevant code.
    Fernando Valente : I just noticed that it does not happen with any other array. The problem is the one being controlled by the array controller.

0 comments:

Post a Comment