Re: Converting NSString to C++ std::string
Re: Converting NSString to C++ std::string
- Subject: Re: Converting NSString to C++ std::string
- From: Michael Ash <email@hidden>
- Date: Sat, 9 May 2009 10:57:52 -0400
On Sat, May 9, 2009 at 8:34 AM, Andrew Wood <email@hidden> 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 visible to all methods in the controller, then do the
> assignment in an action method which is called when a button is clicked.
That you're making this variable an instance variable is the kind of
information that's really handy to put in the initial question.
C++ objects do not work by default as Objective-C instance variables
because their constructors and destructors don't get called. This can
cause crashes like you're seeing and is probably the cause of your
trouble. Enable "Call C++ Default Ctors/Dtors in Objective-C" in your
build settings and see if that helps.
Otherwise, post more complete code and the full stack trace of the crash.
Mike
_______________________________________________
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