On 2013 Oct 09, at 22:06, Shane Stanley <sstan...@myriad-com.com.au> wrote:
> click the close button and choose Revert Changes, I (nearly always) get an > exception thrown on the outline view's datasource method > -outlineView:objectValueForTableColumn:byItem: Issues like this often crop up as soon as you try to make an app which his more complicated than Apple Sample Code :)) > I'm using ARC. ARC doesn't help for KVO observers, notification observers, delegates, manual bindings, or data sources. These must still be managed manually. * * * Here is some typical code "tear down" code. This is for a tabbed window. Note the outline view's delegate and data source being set to nil. * In window controller implementation - (void)windowWillClose:(NSNotification *)aNotification { // The world WILL end. Pull out all of the // power cords ASAP. // Pull cords which are OK to pull more than once … if (!m_tornDown) { // m_tornDown = YES ; … // Pull cords which must be pulled only once … [viewController1 tearDown] [viewController2 tearDown] … } } * Typical -tearDown in view controller (tab) implementation - (void)tearDown { // To fix crash if Split view tries to update as window is closing. // http://lists.apple.com/archives/cocoa-dev/2012/Aug/msg00638.html [splitView setDelegate:nil] ; ContentDataSource* contentDataSource = [contentOutlineView dataSource] ; [contentDataSource setDocument:nil] ; // Messaging table views' delegates and data sources after they are // gone causes indeterminate crashes. [contentOutlineView setDelegate:nil] ; [contentOutlineView setDataSource:nil] ; // Must unbind the things that we bound manually, or bad things happen // as the window closes, for example, Core Data Burps // like this: // "The NSManagedObject with ID:0x16f7f2f0 // <x-coredata://A_UUID/Stark_entity/p20> has been invalidated." [(StarkTableColumn*)[contentOutlineView tableColumnWithIdentifier:@"userDefinedC0"] unbindValue] ; [(StarkTableColumn*)[contentOutlineView tableColumnWithIdentifier:@"userDefinedC1"] unbindValue] ; // And these other views have been seen to get valueForKey: // and/or setValue:forKey: messages after they have been // deallocated, causing crashes. [detailView unbind:@"enaabled"] ; [detailView unbind:@"tooltip"] ; [detailView unbind:@"value"] ; [detailView unbind:@"tokenizingCharacter"] ; [detailView unbind:@"value"] ; [contentOutlineView unbind:@"selectedStarkiTags"] ; [[MAKVONotificationCenter defaultCenter] removeObserver:self] ; [[NSNotificationCenter defaultCenter] removeObserver:self] ; } _______________________________________________ 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