• 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: Clark Cox <email@hidden>
  • Date: Fri, 8 May 2009 09:43:20 -0700

On Fri, May 8, 2009 at 8:39 AM, Alexander Spohr <email@hidden> wrote:
>
> Am 07.05.2009 um 23:38 schrieb Andrew Wood:
>
>> mycppstring = std::string([[myNSTextField stringValue] UTF8String]);
>>
>> But it keeps crashing. What's the recommended way?
>
> Does std::string() copy the char* contents? I guess not (but I don’t use
> C++).

Yes, it does copy the string. As presented, the OP's code is correct,
and should work. OP: You'll have to provide some more information as
to what is actually going wrong (especially where the crash is
actually happening).

--
Clark S. Cox III
email@hidden
_______________________________________________

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

References: 
 >Converting NSString to C++ std::string (From: Andrew Wood <email@hidden>)
 >Re: Converting NSString to C++ std::string (From: Alexander Spohr <email@hidden>)

  • Prev by Date: Re: [Q] Correct way to identify an application, Launch Services, & Spaces
  • Next by Date: Re: [iPhone] Grouped TableView baffling problem
  • Previous by thread: Re: Converting NSString to C++ std::string
  • Next by thread: Re: Converting NSString to C++ std::string
  • Index(es):
    • Date
    • Thread