As you can see from the sample code I provided, I call -beginUpdates and -endUpdates around it.
Full stack trace below. Could the fact that it was being done during a notification being handled have something to do with it? I was able to avoid the exception by calling the code async on the main thread, but that's not really a workable solution for me. Stack Trace:( 0 CoreFoundation 0x00007fff8672c286 __exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff8aad4d5e objc_exception_throw + 43 2 CoreFoundation 0x00007fff8672c0ba +[NSException raise:format:arguments:] + 106 3 Foundation 0x00007fff8c4757d3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169 4 AppKit 0x00007fff8e89f32b -[NSTableView _doUpdatedWorkWithHandler:] + 133 5 AppKit 0x00007fff8ebd5f35 -[NSOutlineView removeItemsAtIndexes:inParent:withAnimation:] + 214 6 MyFrmwrk 0x00000001003b0ddb -[MyOutlineView endEditing] + 347 7 MyFrmwrk 0x00000001003b2177 -[MyCustomEditView controlTextDidEndEditing:] + 215 8 Foundation 0x00007fff8c3c0de2 __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47 9 CoreFoundation 0x00007fff866d4e0a _CFXNotificationPost + 2634 10 Foundation 0x00007fff8c3ad097 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65 11 AppKit 0x00007fff8ecc5f67 -[NSTextField textDidEndEditing:] + 374 12 Foundation 0x00007fff8c3c0de2 __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47 13 CoreFoundation 0x00007fff866d4e0a _CFXNotificationPost + 2634 14 Foundation 0x00007fff8c3ad097 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65 15 AppKit 0x00007fff8ed1d361 -[NSTextView(NSPrivate) _giveUpFirstResponder:] + 438 16 AppKit 0x00007fff8ed0123e -[NSTextView(NSKeyBindingCommands) insertNewline:] + 537 17 CoreFoundation 0x00007fff8671ba1d -[NSObject performSelector:withObject:] + 61 18 AppKit 0x00007fff8ec1bbad -[NSResponder doCommandBySelector:] + 62 19 AppKit 0x00007fff8ecf690e -[NSTextView doCommandBySelector:] + 198 20 AppKit 0x00007fff8eb4ffff -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1799 21 AppKit 0x00007fff8eea1b4a -[NSTextInputContext handleEvent:] + 747 22 AppKit 0x00007fff8ed6deaf -[NSView interpretKeyEvents:] + 248 23 AppKit 0x00007fff8ece6c65 -[NSTextView keyDown:] + 691 24 AppKit 0x00007fff8e7c6544 -[NSWindow sendEvent:] + 7430 25 AppKit 0x00007fff8e75e68f -[NSApplication sendEvent:] + 5593 26 AppKit 0x00007fff8e6f4682 -[NSApplication run] + 555 27 AppKit 0x00007fff8e97380c NSApplicationMain + 867 28 Daylite 0x0000000100009862 main + 34 29 Daylite 0x0000000100009834 start + 52 30 ??? 0x0000000000000005 0x0 + 5 >________________________________ >From: Corbin Dunn <corb...@apple.com> >To: Sebastien Boisvert <sebastienboisv...@yahoo.com> >Cc: cocoa-devDev <cocoa-dev@lists.apple.com> >Sent: Monday, October 24, 2011 11:45:27 AM >Subject: Re: inserting/removing items in NSOutlineView subclass > >hi sebastien, >Are you sure you are calling beginUpdates? At what point are you doing the >code below in your subclass? Also, can you post the complete stack trace? > >If you think it is a bug in appkit, please log it at bugreporter.apple.com -- >but please include a test app, as I haven't been able to reproduce this >myself, and this is the first i've heard of the method not working. > >corbin > >On Oct 22, 2011, at 7:56 PM, Sebastien Boisvert wrote: > >> I have an NSOutlineView subclass that does the following to remove a row: >> >> [self beginUpdates]; >> [selfremoveItemsAtIndexes:[NSIndexSetindexSetWithIndex:editingRow] >> inParent:nilwithAnimation:NSTableViewAnimationEffectNone]; >> [self endUpdates]; >> >> However, when the above runs, I get the following exception: >> >> *** Assertion failure in -[MyOutlineView _doUpdatedWorkWithHandler:], >> /SourceCache/AppKit/AppKit-1138.23/TableView.subproj/NSTableView.m:14634 >> Exception detected while handling key input. >> Exception Name: NSInternalInconsistencyException >> Exception Reason: NSTableView Error: Insert/remove/move only works within a >> -beginUpdates/-endUpdates block. >> >> >> Huh? The row index is valid, I'm not overriding any of the above methods, >> and the calls are balanced, so I don't know why I get this. >> >> I get the same thing if I try to add a row, but discovered that if I have >> the outline view's delete do it instead, that works, but don't know/explain >> why. Unfortunately I can't use that workaround in the situation I use the >> code above for. >> >> Any ideas? >> >> >> Here's the relevant part of the stack trace: >> >> 0 CoreFoundation 0x00007fff8672c286 >> __exceptionPreprocess + 198 >> 1 libobjc.A.dylib 0x00007fff8aad4d5e >> objc_exception_throw + 43 >> 2 CoreFoundation 0x00007fff8672c0ba +[NSException >> raise:format:arguments:] + 106 >> 3 Foundation 0x00007fff8c4757d3 >> -[NSAssertionHandler >> handleFailureInMethod:object:file:lineNumber:description:] + 169 >> 4 AppKit 0x00007fff8e89f32b -[NSTableView >> _doUpdatedWorkWithHandler:] + 133 >> 5 AppKit 0x00007fff8ebd5f35 -[NSOutlineView >> removeItemsAtIndexes:inParent:withAnimation:] + 214 >> _______________________________________________ >> > > > _______________________________________________ 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