2

I have a subclass of NSMutableArray that contains various configuration information along with it's normal array data.

When I archive the subclass, the subclass's encodeWithCoder method is called, but when I unarchive it, the initWithCoder is never called. However, it appears that NSMutableArray's initWithCoder method is called because it returns an NSMutableArray, and not an instance of my subclass.

Any ideas about what's going on?

Mike M
  • 4,358
  • 1
  • 28
  • 48
  • 2
    may be related http://stackoverflow.com/questions/7781248/nskeyedarchiver-returning-unexpected-class – Carl Veazey Sep 18 '13 at 14:13
  • Thanks @CarlVeazey. I agree that it's probably related and I'm seeing similar results to what the referenced post had. I'm wondering if I just need to manage it a different way. – Mike M Sep 18 '13 at 14:20
  • You're welcome. My suggestions would be 1) perhaps avoid using an array subclass to add 'various configuration information' as that sounds like an orthogonal responsibility to typical array responsibilities, and 2) if you do have need of a subclass then your `encodeWithCoder:` implementation would, I suspect, be the first piece of information someone would need to help answer your question. – Carl Veazey Sep 18 '13 at 14:36
  • @CarlVeazey I went with #1 after reading thru similar cases dealing with cluster classes. It was easier just to rewrite my subclass as an NSObject that implements pseudo NSArray methods and it seems like it's working as expected now. Thanks again. – Mike M Sep 18 '13 at 15:18

0 Answers0