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

2009-05-10 Thread Stephen J. Butler
On Sat, May 9, 2009 at 7:45 AM, Andrew Wood wrote: > The controllers header file is as follows. As you can see I decalre dbhost > as a std::string, but dont initialise it. That is a false statement. > The initalisation (which crashes) is done in the doLogin action method. Nope. What happens is

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

2009-05-10 Thread Andrew Wood
The controllers header file is as follows. As you can see I decalre dbhost as a std::string, but dont initialise it. The initalisation (which crashes) is done in the doLogin action method. #import #include @interface CoreController : NSObject { //App Windows IBOutlet NSWin

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

2009-05-09 Thread Michael Ash
On Sat, May 9, 2009 at 8:34 AM, Andrew Wood wrote: > Investigated it a bit further.  It works if I declare the string in the > method where Im doing the assignment, but what I was trying to do, and > really need to do, is decalre the std::string in the app controllers header > file, so that its vi

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

2009-05-09 Thread Andrew Wood
Investigated it a bit further. It works if I declare the string in the method where Im doing the assignment, but what I was trying to do, and really need to do, is decalre the std::string in the app controllers header file, so that its visible to all methods in the controller, then do the

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

2009-05-08 Thread Clark Cox
On Fri, May 8, 2009 at 9:56 AM, Drew Lawson wrote: > According to Alex Curylo: > >> >> On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com wrote: >> >> > mycppstring = std::string([[myNSTextField stringValue] UTF8String]); >> > >> > >> > But it keeps crashing. What's the recommended way? >>

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

2009-05-08 Thread Drew Lawson
According to Alex Curylo: > > On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com 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 w

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

2009-05-08 Thread Clark Cox
On Fri, May 8, 2009 at 8:39 AM, Alexander Spohr 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

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

2009-05-08 Thread Alex Curylo
On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com 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

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

2009-05-08 Thread cocoa learner
Probably you can read this document in following link... http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html This talks about how to C string. And after that you can convert that into a C++ string object. On Fri, May 8, 2009 at 9:39 PM, Alexander Spohr

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

2009-05-08 Thread Jesper Storm Bache
That should work. Where are you crashing - and what is your crash log? My guess is that something else is not right (are you sure that myNSTextField is a valid object)? Jesper Storm Bache On May 7, 2009, at 2:38 PM, Andrew Wood wrote: Im using a library which requires arguments to be C++ st

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

2009-05-08 Thread vinai
--- On Thu, 5/7/09, Andrew Wood wrote: > From: Andrew Wood > Subject: Converting NSString to C++ std::string > To: Cocoa-dev@lists.apple.com > 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 t

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

2009-05-08 Thread Alexander Spohr
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++). See the docs: UTF8String Returns a null-termi

Converting NSString to C++ std::string

2009-05-08 Thread Andrew Wood
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 rec