Re: Converting NSString to C++ std::string
Re: Converting NSString to C++ std::string
- Subject: Re: Converting NSString to C++ std::string
- From: vinai <email@hidden>
- Date: Fri, 8 May 2009 08:42:13 -0700 (PDT)
--- On Thu, 5/7/09, Andrew Wood <email@hidden> wrote:
> From: Andrew Wood <email@hidden>
> Subject: Converting NSString to C++ std::string
> To: email@hidden
> Date: Thursday, May 7, 2009, 4:38 PM
> Im using a library which requires
> arguments to be C++ std::strings, but I need to take the
> value from an NSTextField.
>
> I thought I could do it like this:
>
> std::string mycppstring;
> .
> .
> .
> mycppstring = std::string([[myNSTextField stringValue]
> UTF8String]);
>
> But it keeps crashing. What's the recommended way?
Try:
[thisOptionNSString cStringUsingEncoding: NSASCIIStringEncoding]
where "thisOptionNSString" is of NSString * type, and has already been properly initialized and allocated.
vinai
_______________________________________________
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