> > > >> >> (2) Separate, standalone object. Fancy housekeeping is needed to avoid >> retain cycles, and crashes in corner cases as the document window is closing. > > Quite common. This kind of life cycle management is part of living with Cocoa. > > Consider making this object an NSViewController subclass. >
This is a very interesting thread for me. I have a similar case. I have a view controller which acts as a data source for an outline view. I have another class which builds the model objects that are to be viewed in the outline view. The view controller has an instance of this 'builder' class, and as such presents the objects the builder class creates in the outline view. Mostly it all works fine, but I have occasional crashes that occur when the parent NSDocument instance (which has an instance of the view controller and adds the view to the main window) is closed. I believe I'm hitting corner cases where the outline view still tries to display the objects which have already been released as a result of closing the window. I'm using ARC, and this presents itself as a retain call to objects which have already got a retain count of 0, and this happens in one of the outline view's data source methods. I'm being quite vague here because I'm having a great deal of difficulty debugging this and reproducing anything with any certainty. The reason I chose a stand-alone object was just to separate out that piece of code which gathers the model objects (by parsing some text) on a dispatch queue, from the code that does the displaying. Is there any advice as to how to handle these corner cases? Would it be better (or for that matter, any different) to dispense with the stand-alone 'builder' object and just compute the objects within the view controller? Best wishes, Martin
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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