title: Implicitly construct NSString with std::string
body: <p>When working with Objective-C++, I often find myself using <code>initWithCString</code> to convert from std::string to NSString. To simplify the process, I created a category on NSString as follows:</p>
  
  <pre><code>@implementation NSString (NSStringFromCPP)
  
  +(NSString*)stringFromCppString:(std::string)cppString
  {
      return [[NSString alloc] initWithCString:cppString.c_str() encoding:NSStringEncodingConversionAllowLossy];
  }
  
  
  -(std::string)cppString
  {
      return std::string([self cStringUsingEncoding:NSStringEncodingConversionAllowLossy]);
  }
  
  @end
  </code></pre>
  
  <p>This allows for a fairly easy conversion between NSString and std::string in both directions. It seems there has to be a way to implicitly convert from std::string to NSString though. I understand that there is no such thing as a constructor in Objective-C, so how might the following be accomplished without having to use <code>stringFromCppString</code></p>
  
  <pre><code>-(void)something:(NSString*)someString
  {
      NSLog(@"%@", someString);
  }
  
  
  -(void)activity
  {
      std::string activityName = "Calculator";
      [self something:[NSString stringFromCppString:activityName]];
  }
  </code></pre>
  
  <p>In most cases, code making use of std::string can be separated from code using NSString. However, there is a fair amount of bridging that occurs, and the code becomes distracting with <code>stringFromCppString</code> all over the place.</p>