title: converting NSString to NSData - [NSString dataUsingEncoding] exception
body: <p>I was converting NSString to NSData in order to parse by JSON, but I got the following error.</p>
  
  <pre><code>Terminating app due to uncaught exception 'NSInvalidArgumentException', 
    reason: '-  [__NSCFDictionary dataUsingEncoding:]: 
    unrecognized   selector sent to instance 0x7987d60'
  </code></pre>
  
  <p>The code is as followings:</p>
  
  <pre><code>NSData *data = [str dataUsingEncoding:NSASCIIStringEncoding]; 
  //NSUTF8StringEncoding also failed.
  NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;error];
  </code></pre>
  
  <p>In my opinion, this is because str contains new-line character:'\n'.</p>
  
  <p>Am I correct?</p>
  
  <p>Would somebody please help me to solve this problem?</p>