title: Transform NSData to int in Objective-c
body: <p>I would like to transform NSData to int in Objective-c.</p>
  
  <p>In the following code, "index2" is "15", but "value" is "0".
  (NSLog says "15,0".)</p>
  
  <p>To be exact, "value" must be "15".</p>
  
  <pre><code> NSString *index = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
   NSString *index2 = [index stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
   int value = [index2 intValue];
   NSLog(@"%@,%d",index2,value);
  </code></pre>
  
  <p>Could you tell me how to solve this problem?</p>