title: How to use NSCoder
body: <p>I am developing iphone application.</p>
  
  <p>I use NSCoder.</p>
  
  <p>MyApplication.h</p>
  
  <pre><code>#define ITEMS_KEY @"items"
  #define CATEGORIES_KEY @"categories"
  
  
  #import &lt;UIKit/UIKit.h&gt;
  
  
  @interface MyApplicationData : NSObject &lt;NSCoding, NSCopying&gt; {
      NSMutableArray* items;
      NSMutableArray* categories;
  }
  
  @property (nonatomic ,retain) NSMutableArray* items;
  @property (nonatomic, retain) NSMutableArray* categories;
  
  
  @end
  </code></pre>
  
  <p>Myapplication.m</p>
  
  <pre><code>#import "MyApplicationData.h"
  
  
  @implementation MyApplicationData
  
  @synthesize items;
  @synthesize categories;
  
  #pragma mark NSCoding
  - (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:items forKey:ITEMS_KEY];
    [aCoder encodeObject:categories forKey:CATEGORIES_KEY];
  }
  
  -(id)initWithCoder:(NSCoder *)aDecoder{
    if(self = [super init]){
      self.items = [aDecoder decodeObjectForKey:ITEMS_KEY];
      self.categories = [aDecoder decodeObjectForKey:CATEGORIES_KEY];
    }
    return self;
  }
  
  #pragma mark -
  #pragma mark NSCopying
  -(id)copyWithZone:(NSZone *)zone{
    MyApplicationData* copy = [[[self class]allocWithZone:zone]init];
    items = [self.items copy];
    categories = [self.categories copy];
    return copy;
  }
  
  @end
  </code></pre>
  
  <p>But warnning.</p>
  
  <pre><code>'NSCoder' may not respond to '-decodeDataObjectForKey'
  </code></pre>
  
  <p>How to use NSCoder?</p>