Hi,

        I'm working on my first ARC-enabled app, but am having a problem with 
how to keep my delegate's member data alive.

        At startup (in the delegate's applicationDidFinishLaunching: function), 
my delegate initializes a data object (a member of the delegate) containing 
some NSString members.  Those strings are populated via a call to a helper 
class that is also a member of the delegate.  That helper class call initiates 
an asynchronous set of actions (HTTP), then returns immediately back to the 
delegate.  After returning from that call, the delegate's 
applicationDidFinishLaunching: function simply drops out the bottom.

        When the helper class finishes populating the data from the 
asynchronous HTTP call, it responds with a callback into the delegate.  The 
delegate's callback function responds by showing the main window and populating 
some text fields and buttons according to the strings in the data object.  The 
callback function then drops out the bottom. The dialog shows the correct 
information, meaning that at THAT point in time, the data object was still 
valid.

        My problem comes later, when the user clicks on one of the buttons, 
which calls an action in the delegate.  At this point, I try to extract one of 
the strings from the data object (to launch a browser with the given URL 
string), and it gives me an access violation.  Apparently, my data object has 
been deleted.  That is strange, since it is a member of the delegate.

        I was under the impression that my design was correct, in that member 
objects of the delegate should be initialized in the 
applicationDidFinishLoading: function, right?  So why does the object get 
deleted while my delegate still exists?  More importantly, how do I keep that 
member data object alive so that my delegate's actions can access it?

Thanks,
        Howard






_______________________________________________

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

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

Reply via email to