• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting NSString to C++ std::string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting NSString to C++ std::string


  • Subject: Re: Converting NSString to C++ std::string
  • From: Alex Curylo <email@hidden>
  • Date: Fri, 8 May 2009 09:08:29 -0700


On 8-May-09, at 8:55 AM, email@hidden wrote:

mycppstring = std::string([[myNSTextField stringValue] UTF8String]);


But it keeps crashing. What's the recommended way?

I have no idea, but it works for me to simply assign it without the constructor. Why, here's an example in the file I'm working on right now, fancy that:


- (BOOL)willInterceptURL:(NSURL*)url
{
   // copied from the Carbon version since that works
   std::string urlstring = [[url resourceSpecifier] UTF8String];
   ...
}

I've done the same thing all sorts of places grafting shiny Cocoa stuff onto old C++ code that works and never noticed any issues.

--
Alex Curylo -- email@hidden -- http://www.alexcurylo.com/

"I guess it's pretty bad when you don't start using a new API until
 it's been deprecated." -- Nick Nallick



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Converting NSString to C++ std::string
      • From: Drew Lawson <email@hidden>
  • Prev by Date: Re: Converting NSString to C++ std::string
  • Next by Date: Re: Getting the private IP
  • Previous by thread: Re: Converting NSString to C++ std::string
  • Next by thread: Re: Converting NSString to C++ std::string
  • Index(es):
    • Date
    • Thread