title: Converting NSObject to NSDictionary
body: <p>Hello I a class of type NSObject:</p>
  
  <pre><code>ProductDetails *details = [[ProductDetails alloc] init];
  details.name = @"Soap1";
  details.color = @"Red";
  details.quantity = 4;
  </code></pre>
  
  <p>I want to pass the "details" object to a dictionary. </p>
  
  <p>I did, </p>
  
  <pre><code>NSDictionary *dict = [NSDictionary dictionaryWithObject:details forKey:@"details"];
  </code></pre>
  
  <p>I am passing this dict to another method which performs a check on JSONSerialization:</p>
  
  <pre><code>if(![NSJSONSerialization isValidJSONObject:dict])
  </code></pre>
  
  <p>And I am getting a crash on this check. Am I doing anything wrong here? I know that the details I am getting is a JSON object and I am assigning it to the properties in my ProductDetails class.</p>
  
  <p>Please help me. I am a noob in Objective-C.</p>
  
  <p>I now tried:</p>
  
  <pre><code>NSError* error;
  NSDictionary* json = [NSJSONSerialization JSONObjectWithData:(NSData*)details options:kNilOptions error:&amp;error];
  </code></pre>
  
  <p>All I need here is an easy way to convert details to NSData. </p>
  
  <p>I noticed that I have an array inside my object may be thats why all the ways I tried is throwing an exception. However since this question is becoming to big, I have started an another question thread for it where I have displayed the data I am getting inside the object - <a href="https://stackoverflow.com/questions/19081104/convert-nsobject-to-nsdictionary">https://stackoverflow.com/questions/19081104/convert-nsobject-to-nsdictionary</a></p>