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 assignment in an action method which is called when a button is clicked.

On 8 May 2009, at 17:56, 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?

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:

The only other gotcha I can think of (because it annoys me) is that
std::string does not play nice with null pointers.  Is it possible
that stringValue returns nil?

Hmm, I had one other thought.  There are several std::string
constructors, depending on the parameter type.  In ObjC++, is it
unambiguous at compile time that the expression is "const char*"?

--
Drew Lawson            |  We were taking a vote when
                      |  the ground came up and hit us.
                      |      -- Cylon warrior
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ajwood%40iee.org

This email sent to ajw...@iee.org

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to