Reporting Bugs in Apple Sample Code (NSOutlineView, NSTreeController and Bindings)

  • Hi Guys,

    Probably not one of their most pressing matters, but should I file a
    radar with a simple fix for a bug in one of Apple's sample codes?  Is
    it useful for them, as I'm sure loads of developers look at this
    particular sample code?

    It's the one called SourceView, which shows how to build up a sample
    source list à la iTunes.  The drag and drop method has an error.

    // myWindowController.m
    // -handleInternalDrops:

    NSInteger i;
    for (i = ([newNodes count] - 1); i >=0; i--)
    {
      [treeController moveNode:[newNodes objectAtIndex:i]
    toIndexPath:indexPath];
    }

    should read:

    NSEnumerator *enumerator = [newNodes reverseObjectEnumerator]
    NSMutableArray *reverseDragArray = [[NSMutableArray alloc] init];
    for(id item in enumerator)
      [reverseDragArray addObject:item];

    [treeController moveNodes:reverseDragArray toIndexPath:indexPath];

    Their way means the dragged nodes end up all over the place when
    dragging into a group (folder) as the indexPath is not updated after
    each node is moved. Obviously I've use fast enumeration to clean it up
    too, but the idea is to not move the nodes one at a time!

    Other than that its great sample code if you want the iTunes look and
    need to work out using NSOutlineView, NSTreeController and Bindings,
    check it out:

    http://developer.apple.com/samplecode/SourceView/index.html

    Jonathan
  • On Jan 12, 2008, at 10:46 AM, Jonathan Dann wrote:

    > Probably not one of their most pressing matters, but should I file a
    > radar with a simple fix for a bug in one of Apple's sample codes?
    > Is it useful for them,
    >
    Yes.

    mmalc
  • On Jan 12, 2008, at 10:46 AM, Jonathan Dann wrote:

    > Probably not one of their most pressing matters, but should I file a
    > radar with a simple fix for a bug in one of Apple's sample codes?
    > Is it useful for them, as I'm sure loads of developers look at this
    > particular sample code?

    You most certainly should. File away!

    j o a r
  • > Yes.
    >
    > mmalc
    >
    >> You most certainly should. File away!
    >>
    >> j o a r

    Thanks to you both!  I've filed my first bug!

    Problem ID: 5685402

    Just in case people read in this future the reverse enumerator bit in
    the first post was wrong, that only applies when moving multiple nodes
    one at a time in a tree view.  The NSTreeController method -
    moveNodes:toIndexPath should replace the code:

    NSInteger i;
    for (i = ([newNodes count] - 1); i >=0; i--)
    {
      [treeController moveNode:[newNodes objectAtIndex:i]
    toIndexPath:indexPath];
    }

    in the -handleInternalDrops:withIndexPath:

    Jonathan
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today