On Sat, May 9, 2009 at 7:45 AM, Andrew Wood <ajw...@iee.org> 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 that Objective-C allocates your object,
including the bytes needed for dbhost, zero fills all the memory, and
then returns it from alloc. The problem is that std::string
constructor is NEVER called, yet all the bytes are there.

In your doLogin method, std::string's assignment operator is called,
not the constructor. The assignment operator then crashes because the
std::string memory was never initialized. It could be crashing for any
number of reasons. Possibly trying to dereference a NULL pointer in
the old string. Possibly the vtable for std::string doesn't exist.
Etc, etc.

That's why Michael Ash's solution will probably fix your problem:

"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."
_______________________________________________

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