title: IOS/Objective-C: Convert NSArray of Custom Objects to JSON
body: <p>Based on <a href="https://stackoverflow.com/questions/13961590/convert-nsarray-into-array-of-json-objects">the accepted answer to this answer</a>, I am trying to send an array of custom objects via JSON to a server.</p>
  
  <p>However, the following code to serialize the objects is crashing.  I think it because NSJSONSerialization can only accept an NSDictionary, not a custom object.</p>
  
  <pre><code>NSArray &lt;Offers *&gt; *offers = [self getOffers:self.customer];
  //Returns a valid array of offers as far as I can tell.
  NSError *error;
  //Following line crashes
  NSData * JSONData = [NSJSONSerialization dataWithJSONObject:offers
                                                      options:kNilOptions
                                                        error:&amp;error];
  </code></pre>
  
  <p>Can anyone suggest way to convert an array of custom objects to JSON?</p>